所以,假设我正在编写一个Web服务器,我想支持"非常大"的文件上传.让我们进一步假设我的意思是通过标准的multipart/form-data MIME类型来实现这一点.我应该说我正在使用erlang并且我计划在返回时收集http数据包erlang:decode_packet/2,但我不想实际收集请求正文,直到http请求处理程序找到了上传内容的位置.我是不是该
a)反过来收集身体,忽略了它非常大的可能性,因此可能因内存不足而导致服务器崩溃?
b)在标题处理完之后,不要在套接字上接收任何(可能不存在的)请求体?
c)做点什么?
答案c的示例可能是:产生另一个进程来收集并将上载的内容写入临时位置(以便最小化内存使用),同时将该位置提供给http请求处理程序以供将来处理.但我只是不知道 - 这里有标准技术吗?
我们有一个在 weblogic 应用服务器上运行的 web 应用程序(JQuery 和 Spring)。应用服务器前面有一个apache http服务器。所有传入的请求都将通过 Web 服务器到达应用程序服务器。
现在我们有一个要求,我们必须验证传入的 http 请求标头中的值,如果存在,则必须将请求发送到应用程序服务器。如果没有,我们将阻止请求,然后向最终用户显示一个静态错误页面。
我想知道我们是否可以在apache http服务器中实现这个逻辑。请指教。
我一直在修改一些示例代码以用于 Web 服务器,这样我就可以在服务器和客户端上运行 dart。但是,我决定要检查 Web 服务器的性能,除了崩溃之外,我印象最深刻。我在 Ubuntu 上使用“siege”包,使用少量 URL 为网站生成大量流量。
我已经看到它每秒传输 1000 个事务,这对我来说是非常可接受的,但是在运行两到三分钟后,它要么崩溃要么挂起(如果我增加 new_gen_heap_size)。
#import('dart:io');
class FCServer {
String basePath;
void send404(HttpResponse response)
{
response.statusCode = HttpStatus.NOT_FOUND;
response.outputStream.close();
}
void handleRequest(HttpRequest request, HttpResponse response)
{
final String path = request.path == '/' ? '/index.html' : request.path;
final File file = new File('${basePath}${path}');
file.exists().then((bool found) {
if (found)
{
file.fullPath().then((String fullPath) {
if (!fullPath.startsWith(basePath))
{
send404(response);
}
else
{
//print("delivering $fullPath");
response.headers.add("Cache-Control", "max-age=3600");
//file.openInputStream().pipe(response.outputStream);
var file = new File("$fullPath");
//response.headers.set(HttpHeaders.CONTENT_TYPE, "$contentType; …Run Code Online (Sandbox Code Playgroud) 我使用 Apache HTTP Server mod_proxy 作为我的客户端和服务器之间的代理服务器。我能够从我的客户端连接到我的代理服务器。然后客户端能够建立连接并将数据发送到服务器。但在中间,某处连接丢失,并给出以下错误:
(OS 10054)An existing connection was forcibly closed by the remote host. : proxy: prefetch request body failed to 10.131.x.x:80 (10.131.x.x) from 10.131.y.y ()
Run Code Online (Sandbox Code Playgroud)
我曾尝试添加 keep alive 和其他属性,但它没有解决我的问题。这是我的 httpd.config 文件更改:
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
<IfModule mod_proxy.c>
ProxyRequests On
ProxyVia On
</IfModule>
<Proxy *>
Order deny,allow
Deny from all
Allow from 10.131.x.x
</Proxy>
Run Code Online (Sandbox Code Playgroud)
还添加了这个变量:
KeepAlive On
MaxKeepAliveRequests 0
KeepAliveTimeout 15
Listen 8080
Run Code Online (Sandbox Code Playgroud)
请需要知道是否有人遇到过同样的问题并解决了它。
谢谢,阿林达姆。
作为标题,什么时候使用 httptest.Server 和 httptest.ResponseRecorder?
在我看来,我还可以使用 httptest.Server 测试我的处理程序以返回正确的响应。我可以简单地启动一个带有我的处理程序实现的 httptest.Server,然后对响应的主体进行验证。
如果我错了,请纠正,我正在学习 Go + TDD
在我的 HTTP 服务器上,我试图允许用户通过这种形式上传图片:
<form action="/?command=saveImage" method="post" enctype="multipart/form-data">
<input type="file" name="images" multiple="multiple"/>
<input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
我正在使用此源上传图像:http : //embarcadero.newsgroups.archived.at/public.delphi.internet.winsock/201107/1107276163.html并更改了 ProcessMimePart 程序以便以正确的格式保存图像:
procedure ProcessMimePart(var aDecoder: TIdMessageDecoder;
var aMsgEnd: Boolean);
var
LMStream: TMemoryStream;
LNewDecoder: TIdMessageDecoder;
fileName, fileExtension: string;
begin
fileName := aDecoder.fileName;
fileExtension := GetFileExtension(fileName);
if (fileExtension <> 'jpg') and (fileExtension <> 'png')
and (fileExtension <> 'bmp') then
begin
Exit;
end;
LMStream := TMemoryStream.Create;
try
LNewDecoder := aDecoder.ReadBody(LMStream, aMsgEnd);
try
LMStream.Position := 0;
TSaveImageController.WriteImage(fileName, fileExtension, LMStream);
except
LNewDecoder.Free;
raise;
end;
aDecoder.Free;
aDecoder …Run Code Online (Sandbox Code Playgroud) 我想使用http-server和forever.js将我的应用程序部署到远程ubuntu服务器.但forever.js需要JS文件的路径,而不是可执行文件.所以我无法将密钥传递给http-server.到目前为止,最好的解决方案是通过npm在本地安装http-server并运行如下:forever start ./node_modules/http-server/bin/http-server.但在这种情况下,我无法设置端口和其他选项.什么是最佳做法?
我需要处理HTTP请求,使用com.sun.net.httpserver.HttpServer以下URL模式触发请求:
http://somehost:9000/<var>/<service>
<var> 是一个传递给的参数 <service>
<service> 是服务器提供的预定义服务
问题是上下文路径在编译时是未知的(因为<var>)因此我不能只调用createContext(String path, HttpHandler handler).如何将这种"动态"上下文绑定到特定HttpHandler实例?
我目前正在使用以下命令Angular在服务器上运行http-server:http-server ./ index.html.
这适用于角度细.链接点击工作.虽然如果我直接进入URLa .该应用程序崩溃./route-nameurl.com/route-name
我正在使用,lite-server但lite-server建议的文档只在开发中使用它.使用时lite-server,我可以直接输入一个URL,route它工作正常.
如何配置http-server能够使用页面路由输入URL地址,或者Angular在生产环境中运行的另一种好方法是什么?
我用Angular2作为客户端,NodeJS作为服务器构建了一个Web应用程序.我想用npm的http-server应用程序服务它而没有任何配置,但我想知道它可以同时处理多少个客户端?
httpserver ×10
apache ×2
file-upload ×2
node.js ×2
angular ×1
daemon ×1
dart ×1
delphi ×1
erlang ×1
go ×1
heap ×1
http ×1
http-headers ×1
httpd.conf ×1
indy ×1
java ×1
mod-proxy ×1
proxy ×1
tdd ×1
ubuntu ×1
unit-testing ×1