libpurple/http.c

changeset 34286
8d0979967d05
parent 34272
8df870b218ca
child 34287
6cd0c77b1f6a
equal deleted inserted replaced
34285:bae262cc5585 34286:8d0979967d05
866 int hdrline_len = eol - hdrline; 866 int hdrline_len = eol - hdrline;
867 867
868 hdrline[hdrline_len] = '\0'; 868 hdrline[hdrline_len] = '\0';
869 869
870 if (hdrline[0] == '\0') { 870 if (hdrline[0] == '\0') {
871 if (!hc->main_header_got && hc->is_keepalive) { 871 if (!hc->main_header_got) {
872 if (purple_debug_is_verbose()) { 872 if (purple_debug_is_verbose() &&
873 hc->is_keepalive)
874 {
873 purple_debug_misc("http", "Got keep-" 875 purple_debug_misc("http", "Got keep-"
874 "alive terminator from previous" 876 "alive terminator from previous"
875 " request\n"); 877 " request\n");
878 } else {
879 purple_debug_warning("http", "Got empty"
880 " line at the beginning - this "
881 "may be a HTTP server quirk\n");
876 } 882 }
877 } else if (!hc->main_header_got) {
878 hc->response->code = 0;
879 purple_debug_warning("http",
880 "Main header not present\n");
881 _purple_http_error(hc, _("Error parsing HTTP"));
882 return FALSE;
883 } else /* hc->main_header_got */ { 883 } else /* hc->main_header_got */ {
884 hc->headers_got = TRUE; 884 hc->headers_got = TRUE;
885 if (purple_debug_is_verbose()) { 885 if (purple_debug_is_verbose()) {
886 purple_debug_misc("http", "Got headers " 886 purple_debug_misc("http", "Got headers "
887 "end\n"); 887 "end\n");
937 { 937 {
938 len = hc->length_expected - hc->length_got; 938 len = hc->length_expected - hc->length_got;
939 } 939 }
940 if (hc->request->max_length >= 0) { 940 if (hc->request->max_length >= 0) {
941 if (hc->length_got + len > hc->request->max_length) { 941 if (hc->length_got + len > hc->request->max_length) {
942 purple_debug_warning("http",
943 "Maximum length exceeded, truncating\n");
942 len = hc->request->max_length - hc->length_got; 944 len = hc->request->max_length - hc->length_got;
943 hc->length_expected = hc->request->max_length; 945 hc->length_expected = hc->request->max_length;
944 } 946 }
945 } 947 }
946 hc->length_got += len; 948 hc->length_got += len;
1084 return FALSE; 1086 return FALSE;
1085 } 1087 }
1086 1088
1087 /* EOF */ 1089 /* EOF */
1088 if (len == 0) { 1090 if (len == 0) {
1091 if (hc->request->max_length == 0) {
1092 /* It's definitely YHttpServer quirk. */
1093 purple_debug_warning("http", "Got EOF, but no data was "
1094 "expected (this may be a server quirk)\n");
1095 hc->length_expected = hc->length_got;
1096 }
1089 if (hc->length_expected >= 0 && 1097 if (hc->length_expected >= 0 &&
1090 hc->length_got < hc->length_expected) { 1098 hc->length_got < hc->length_expected) {
1091 purple_debug_warning("http", "No more data while reading" 1099 purple_debug_warning("http", "No more data while reading"
1092 " contents\n"); 1100 " contents\n");
1093 _purple_http_error(hc, _("Error parsing HTTP")); 1101 _purple_http_error(hc, _("Error parsing HTTP"));
1099 purple_debug_info("http", "Keep-alive connection " 1107 purple_debug_info("http", "Keep-alive connection "
1100 "expired (when reading), retrying...\n"); 1108 "expired (when reading), retrying...\n");
1101 purple_http_conn_retry(hc); 1109 purple_http_conn_retry(hc);
1102 return FALSE; 1110 return FALSE;
1103 } else { 1111 } else {
1104 purple_debug_warning("http", "No more data while " 1112 if (g_ascii_strcasecmp(purple_http_headers_get(
1105 "parsing headers\n"); 1113 hc->response->headers, "Server"),
1106 _purple_http_error(hc, _("Error parsing HTTP")); 1114 "YHttpServer") == 0)
1107 return FALSE; 1115 {
1116 purple_debug_warning("http", "No more data "
1117 "while parsing headers (YHttpServer "
1118 "quirk)\n");
1119 hc->headers_got = TRUE;
1120 hc->length_expected = hc->length_got = 0;
1121 } else {
1122 purple_debug_warning("http", "No more data "
1123 "while parsing headers\n");
1124 _purple_http_error(hc, _("Error parsing HTTP"));
1125 return FALSE;
1126 }
1108 } 1127 }
1109 } 1128 }
1110 1129
1111 if (!hc->headers_got && len > 0) { 1130 if (!hc->headers_got && len > 0) {
1112 if (!_purple_http_recv_headers(hc, buf, len)) 1131 if (!_purple_http_recv_headers(hc, buf, len))
2250 2269
2251 purple_http_socket_dontwatch(hs); 2270 purple_http_socket_dontwatch(hs);
2252 hs->is_busy = FALSE; 2271 hs->is_busy = FALSE;
2253 host = hs->host; 2272 host = hs->host;
2254 2273
2274 if (host == NULL) {
2275 purple_http_socket_close_free(hs);
2276 return;
2277 }
2278
2255 if (invalidate) { 2279 if (invalidate) {
2256 host->sockets = g_slist_remove(host->sockets, hs); 2280 host->sockets = g_slist_remove(host->sockets, hs);
2257 purple_http_socket_close_free(hs); 2281 purple_http_socket_close_free(hs);
2258 } 2282 }
2259 2283
2260 if (host != NULL) 2284 purple_http_keepalive_host_process_queue(host);
2261 purple_http_keepalive_host_process_queue(host);
2262 } 2285 }
2263 2286
2264 void 2287 void
2265 purple_http_keepalive_pool_set_limit_per_host(PurpleHttpKeepalivePool *pool, 2288 purple_http_keepalive_pool_set_limit_per_host(PurpleHttpKeepalivePool *pool,
2266 guint limit) 2289 guint limit)

mercurial