Mercurial > hg > nginx-quic
comparison src/http/ngx_http_spdy.c @ 5689:5d55f03b1e12
SPDY: removed ngx_http_spdy_state_headers_error().
The function just calls ngx_http_spdy_state_headers_skip() most of the time.
There was also an attempt of optimization to stop parsing if the client already
closed connection, but it looks strange and unfinished anyway.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Wed, 30 Apr 2014 20:34:20 +0400 |
parents | 86232c95623d |
children | fb56f5d612a0 |
comparison
equal
deleted
inserted
replaced
5688:86232c95623d | 5689:5d55f03b1e12 |
---|---|
100 static u_char *ngx_http_spdy_state_head(ngx_http_spdy_connection_t *sc, | 100 static u_char *ngx_http_spdy_state_head(ngx_http_spdy_connection_t *sc, |
101 u_char *pos, u_char *end); | 101 u_char *pos, u_char *end); |
102 static u_char *ngx_http_spdy_state_syn_stream(ngx_http_spdy_connection_t *sc, | 102 static u_char *ngx_http_spdy_state_syn_stream(ngx_http_spdy_connection_t *sc, |
103 u_char *pos, u_char *end); | 103 u_char *pos, u_char *end); |
104 static u_char *ngx_http_spdy_state_headers(ngx_http_spdy_connection_t *sc, | 104 static u_char *ngx_http_spdy_state_headers(ngx_http_spdy_connection_t *sc, |
105 u_char *pos, u_char *end); | |
106 static u_char *ngx_http_spdy_state_headers_error(ngx_http_spdy_connection_t *sc, | |
107 u_char *pos, u_char *end); | 105 u_char *pos, u_char *end); |
108 static u_char *ngx_http_spdy_state_headers_skip(ngx_http_spdy_connection_t *sc, | 106 static u_char *ngx_http_spdy_state_headers_skip(ngx_http_spdy_connection_t *sc, |
109 u_char *pos, u_char *end); | 107 u_char *pos, u_char *end); |
110 static u_char *ngx_http_spdy_state_window_update(ngx_http_spdy_connection_t *sc, | 108 static u_char *ngx_http_spdy_state_window_update(ngx_http_spdy_connection_t *sc, |
111 u_char *pos, u_char *end); | 109 u_char *pos, u_char *end); |
1098 sizeof(ngx_table_elt_t)) | 1096 sizeof(ngx_table_elt_t)) |
1099 != NGX_OK) | 1097 != NGX_OK) |
1100 { | 1098 { |
1101 ngx_http_spdy_close_stream(sc->stream, | 1099 ngx_http_spdy_close_stream(sc->stream, |
1102 NGX_HTTP_INTERNAL_SERVER_ERROR); | 1100 NGX_HTTP_INTERNAL_SERVER_ERROR); |
1103 return ngx_http_spdy_state_headers_error(sc, pos, end); | 1101 return ngx_http_spdy_state_headers_skip(sc, pos, end); |
1104 } | 1102 } |
1105 | 1103 |
1106 if (ngx_array_init(&r->headers_in.cookies, r->pool, 2, | 1104 if (ngx_array_init(&r->headers_in.cookies, r->pool, 2, |
1107 sizeof(ngx_table_elt_t *)) | 1105 sizeof(ngx_table_elt_t *)) |
1108 != NGX_OK) | 1106 != NGX_OK) |
1109 { | 1107 { |
1110 ngx_http_spdy_close_stream(sc->stream, | 1108 ngx_http_spdy_close_stream(sc->stream, |
1111 NGX_HTTP_INTERNAL_SERVER_ERROR); | 1109 NGX_HTTP_INTERNAL_SERVER_ERROR); |
1112 return ngx_http_spdy_state_headers_error(sc, pos, end); | 1110 return ngx_http_spdy_state_headers_skip(sc, pos, end); |
1113 } | 1111 } |
1114 } | 1112 } |
1115 | 1113 |
1116 while (sc->entries) { | 1114 while (sc->entries) { |
1117 | 1115 |
1133 | 1131 |
1134 if (rc == NGX_DECLINED) { | 1132 if (rc == NGX_DECLINED) { |
1135 /* TODO logging */ | 1133 /* TODO logging */ |
1136 ngx_http_finalize_request(r, | 1134 ngx_http_finalize_request(r, |
1137 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); | 1135 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); |
1138 return ngx_http_spdy_state_headers_error(sc, pos, end); | 1136 return ngx_http_spdy_state_headers_skip(sc, pos, end); |
1139 } | 1137 } |
1140 | 1138 |
1141 if (rc != NGX_OK) { | 1139 if (rc != NGX_OK) { |
1142 ngx_http_spdy_close_stream(sc->stream, | 1140 ngx_http_spdy_close_stream(sc->stream, |
1143 NGX_HTTP_INTERNAL_SERVER_ERROR); | 1141 NGX_HTTP_INTERNAL_SERVER_ERROR); |
1144 return ngx_http_spdy_state_headers_error(sc, pos, end); | 1142 return ngx_http_spdy_state_headers_skip(sc, pos, end); |
1145 } | 1143 } |
1146 | 1144 |
1147 /* null-terminate the last processed header name or value */ | 1145 /* null-terminate the last processed header name or value */ |
1148 *buf->pos = '\0'; | 1146 *buf->pos = '\0'; |
1149 | 1147 |
1188 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 1186 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1189 "client sent invalid header line"); | 1187 "client sent invalid header line"); |
1190 | 1188 |
1191 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | 1189 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
1192 | 1190 |
1193 return ngx_http_spdy_state_headers_error(sc, pos, end); | 1191 return ngx_http_spdy_state_headers_skip(sc, pos, end); |
1194 | 1192 |
1195 default: /* NGX_HTTP_PARSE_INVALID_HEADER */ | 1193 default: /* NGX_HTTP_PARSE_INVALID_HEADER */ |
1196 | 1194 |
1197 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 1195 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1198 "client sent invalid HEADERS spdy frame"); | 1196 "client sent invalid HEADERS spdy frame"); |
1214 | 1212 |
1215 if (rc == NGX_HTTP_PARSE_INVALID_REQUEST) { | 1213 if (rc == NGX_HTTP_PARSE_INVALID_REQUEST) { |
1216 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | 1214 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
1217 } | 1215 } |
1218 | 1216 |
1219 return ngx_http_spdy_state_headers_error(sc, pos, end); | 1217 return ngx_http_spdy_state_headers_skip(sc, pos, end); |
1220 } | 1218 } |
1221 } | 1219 } |
1222 | 1220 |
1223 if (buf->pos != buf->last || sc->zstream_in.avail_in) { | 1221 if (buf->pos != buf->last || sc->zstream_in.avail_in) { |
1224 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 1222 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
1237 *buf->pos = '\0'; | 1235 *buf->pos = '\0'; |
1238 | 1236 |
1239 ngx_http_spdy_run_request(r); | 1237 ngx_http_spdy_run_request(r); |
1240 | 1238 |
1241 return ngx_http_spdy_state_complete(sc, pos, end); | 1239 return ngx_http_spdy_state_complete(sc, pos, end); |
1242 } | |
1243 | |
1244 | |
1245 static u_char * | |
1246 ngx_http_spdy_state_headers_error(ngx_http_spdy_connection_t *sc, u_char *pos, | |
1247 u_char *end) | |
1248 { | |
1249 if (sc->connection->error) { | |
1250 return ngx_http_spdy_state_internal_error(sc); | |
1251 } | |
1252 | |
1253 return ngx_http_spdy_state_headers_skip(sc, pos, end); | |
1254 } | 1240 } |
1255 | 1241 |
1256 | 1242 |
1257 static u_char * | 1243 static u_char * |
1258 ngx_http_spdy_state_headers_skip(ngx_http_spdy_connection_t *sc, u_char *pos, | 1244 ngx_http_spdy_state_headers_skip(ngx_http_spdy_connection_t *sc, u_char *pos, |