r17682 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17681‎ | r17682 | r17683 >
Date:21:21, 14 November 2006
Author:river
Status:old
Tags:
Comment:
when sending errors, ensure we either chunk the reply or don't try keepalive
Modified paths:
  • /trunk/willow/src/include/flowio.h (modified) (history)
  • /trunk/willow/src/willow/chunking.cc (modified) (history)
  • /trunk/willow/src/willow/flowio.cc (modified) (history)
  • /trunk/willow/src/willow/whttp.cc (modified) (history)

Diff [purge]

Index: trunk/willow/src/include/flowio.h
@@ -294,7 +294,7 @@
295295
296296 virtual sink_result bf_transform(char const *, size_t, ssize_t &discard) = 0;
297297 virtual sink_result bf_eof(void) {
298 - return sink_result_okay;
 298+ return sink_result_finished;
299299 }
300300
301301 sink_result data_ready(char const *buf, size_t len, ssize_t &discard) {
Index: trunk/willow/src/willow/flowio.cc
@@ -348,6 +348,7 @@
349349 streamsize size;
350350 if (_cached) {
351351 if (!_cached_size) {
 352+ _sp_data_empty();
352353 _sp_completed_callee();
353354 return false;
354355 }
@@ -359,6 +360,7 @@
360361
361362 size = _file.readsome(_fbuf, 16384);
362363 if (size == 0) {
 364+ _sp_data_empty();
363365 _sp_completed_callee();
364366 return false;
365367 } else if (_file.fail()) {
Index: trunk/willow/src/willow/chunking.cc
@@ -39,6 +39,7 @@
4040 io::sink_result
4141 chunking_filter::bf_eof(void)
4242 {
 43+ WDEBUG((WLOG_DEBUG, "chunking_filter: EOF"));
4344 _buf.add("\r\n0\r\n", 5, false);
4445 return io::sink_result_finished;
4546 }
Index: trunk/willow/src/willow/whttp.cc
@@ -937,7 +937,7 @@
938938 _error_headers->add("Date", current_time_str);
939939 _error_headers->add("Expires", current_time_str);
940940 _error_headers->add("Server", my_version);
941 - _error_headers->add("Connection", "close");
 941+
942942 _error_headers->add("Content-Type", "text/html;charset=UTF-8");
943943
944944 _error_body = io::file_spigot::from_path(error_files[errnum], true);
@@ -950,6 +950,12 @@
951951 _error_headers->completed_callee(this, &httpcllr::error_send_headers_done);
952952 _error_headers->error_callee(this, &httpcllr::error_send_done);
953953
 954+ /*
 955+ * Can we chunk the error?
 956+ */
 957+ if (_header_parser->_http_vers != http11)
 958+ _error_headers->add("Connection", "close");
 959+
954960 _error_headers->sp_connect(_client_sink);
955961 _error_headers->sp_uncork();
956962 }
@@ -962,7 +968,16 @@
963969 _error_body->error_callee(this, &httpcllr::error_send_done);
964970
965971 _error_body->sp_connect(_error_filter);
966 - _error_filter->sp_connect(_client_sink);
 972+ if (_header_parser->_http_vers == http11) {
 973+ _chunking_filter = new chunking_filter;
 974+ _error_filter->sp_connect(_chunking_filter);
 975+ _chunking_filter->sp_connect(_client_sink);
 976+ } else {
 977+ _header_parser->_no_keepalive = true;
 978+ _header_parser->_force_keepalive = false;
 979+ _error_filter->sp_connect(_client_sink);
 980+ }
 981+
967982 _error_body->sp_uncork();
968983 }
969984