dart – 使用F5发送垃圾邮件时Web服务器崩溃

dart – 使用F5发送垃圾邮件时Web服务器崩溃,第1张

概述我制作了一个简单的Web服务器,但每次我在很短的时间内刷新页面时都会崩溃.我只需在浏览器中输入127.0.0.1:8080,然后使用F5输入垃圾邮件.以下是重现此问题的代码: void main(){ HttpServer server = new HttpServer(); server.addRequestHandler((req) => true, handleGET); se 我制作了一个简单的Web服务器,但每次我在很短的时间内刷新页面时都会崩溃.我只需在浏览器中输入127.0.0.1:8080,然后使用F5输入垃圾邮件.以下是重现此问题的代码:

@H_403_8@

@H_403_8@

voID main(){  httpServer server = new httpServer();  server.addRequestHandler((req) => true,handleGET);  server.Listen('127.0.0.1',8080);}voID handleGET(httpRequest req,httpResponse res){  var requestedfile = ".${req.path}";  if(req.path == "/")  {    requestedfile = requestedfile.concat("index.HTML");  }  file file = new file(requestedfile);  file.exists().then((bool found) {    if(found)    {      file.openinputStream().pipe(res.outputStream);    }    else    {      res.statusCode = httpStatus.NOT_FOUND;      res.outputStream.close();    }  });}

我得到的错误如下:@H_403_8@

@H_403_8@

Unhandled exception:StreamException: Stream closed#0      _SocketoutputStream._write (dart:io:6017:30)#1      _httpResponse._writeheader (dart:io:5981:18)#2      _httpRequestResponseBase._ensureheadersSent (dart:io:2696:19)#3      _httpResponse._streamClose (dart:io:2921:23)#4      _httpOutputStream.close (dart:io:3078:36)#5      _pipe.<anonymous closure> (dart:io:6271:28)#6      _BaseDatainputStream._checkScheduleCallbacks.issueCloseCallback (dart:io:6231:59)#7      _Timer._createTimerHandler._handleTimeout (dart:io:6804:28)#8      _Timer._createTimerHandler._handleTimeout (dart:io:6812:7)#9      _Timer._createTimerHandler.<anonymous closure> (dart:io:6820:23)#10     _ReceivePortImpl._handleMessage (dart:isolate-patch:37:92)

通常在此市长异常之前,我收到一堆警告,如WSASend失败:10053,但那些不会使服务器崩溃.如果此问题与某些特定实现有关,我在windows上工作.@H_403_8@解决方法 因为您很快就会重新加载,所以您的代码最终会尝试写入已经关闭的套接字.因此,您应该捕获StreamException并忽略它.可以说io库应该可以帮到你更多.我刚刚提交了这个错误:

@H_403_8@

http://code.google.com/p/dart/issues/detail?id=7334&thanks=7334&ts=1355280746@H_403_8@ 总结

以上是内存溢出为你收集整理的dart – 使用F5发送垃圾邮件时Web服务器崩溃全部内容,希望文章能够帮你解决dart – 使用F5发送垃圾邮件时Web服务器崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1059284.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存