nxt_h1proto.c (467:ee5f278e8c81) nxt_h1proto.c (480:11b28d6fc462)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

--- 176 unchanged lines hidden (view full) ---

185static void
186nxt_h1p_header_parse(nxt_task_t *task, void *obj, void *data)
187{
188 size_t size;
189 nxt_int_t ret;
190 nxt_buf_t *in, *b;
191 nxt_conn_t *c;
192 nxt_h1proto_t *h1p;
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

--- 176 unchanged lines hidden (view full) ---

185static void
186nxt_h1p_header_parse(nxt_task_t *task, void *obj, void *data)
187{
188 size_t size;
189 nxt_int_t ret;
190 nxt_buf_t *in, *b;
191 nxt_conn_t *c;
192 nxt_h1proto_t *h1p;
193 nxt_http_status_t status;
193 nxt_http_request_t *r;
194 nxt_socket_conf_joint_t *joint;
195
196 c = obj;
197 h1p = data;
198
199 nxt_debug(task, "h1p header parse");
200

--- 58 unchanged lines hidden (view full) ---

259
260 ret = nxt_http_fields_process(r->fields, &nxt_h1p_fields_hash, r);
261
262 if (nxt_fast_path(ret == NXT_OK)) {
263 r->state->ready_handler(task, r, NULL);
264 return;
265 }
266
194 nxt_http_request_t *r;
195 nxt_socket_conf_joint_t *joint;
196
197 c = obj;
198 h1p = data;
199
200 nxt_debug(task, "h1p header parse");
201

--- 58 unchanged lines hidden (view full) ---

260
261 ret = nxt_http_fields_process(r->fields, &nxt_h1p_fields_hash, r);
262
263 if (nxt_fast_path(ret == NXT_OK)) {
264 r->state->ready_handler(task, r, NULL);
265 return;
266 }
267
267 } else if (ret == NXT_AGAIN) {
268 /* ret == NXT_ERROR */
269
270 nxt_http_request_error(task, r, NXT_HTTP_BAD_REQUEST);
271 return;
272 }
273
274 if (ret == NXT_AGAIN) {
268 in = c->read;
269
270 if (nxt_buf_mem_free_size(&in->mem) == 0) {
271 size = r->socket_conf->large_header_buffer_size;
272
273 if (size <= (size_t) nxt_buf_mem_used_size(&in->mem)
274 || h1p->nbuffers >= r->socket_conf->large_header_buffers)
275 {

--- 17 unchanged lines hidden (view full) ---

293 h1p->buffers = in;
294 c->read = b;
295 }
296
297 nxt_conn_read(task->thread->engine, c);
298 return;
299 }
300
275 in = c->read;
276
277 if (nxt_buf_mem_free_size(&in->mem) == 0) {
278 size = r->socket_conf->large_header_buffer_size;
279
280 if (size <= (size_t) nxt_buf_mem_used_size(&in->mem)
281 || h1p->nbuffers >= r->socket_conf->large_header_buffers)
282 {

--- 17 unchanged lines hidden (view full) ---

300 h1p->buffers = in;
301 c->read = b;
302 }
303
304 nxt_conn_read(task->thread->engine, c);
305 return;
306 }
307
301 /* ret == NXT_ERROR */
308 switch (ret) {
302
309
303 nxt_http_request_error(task, r, NXT_HTTP_BAD_REQUEST);
310 case NXT_HTTP_PARSE_INVALID:
311 status = NXT_HTTP_BAD_REQUEST;
312 break;
313
314 case NXT_HTTP_PARSE_TOO_LARGE_FIELD:
315 status = NXT_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE;
316 break;
317
318 default:
319 case NXT_ERROR:
320 status = NXT_HTTP_INTERNAL_SERVER_ERROR;
321 break;
322 }
323
324 nxt_http_request_error(task, r, status);
304 return;
305
306fail:
307
308 nxt_h1p_conn_close(task, c, h1p);
309}
310
311

--- 687 unchanged lines hidden ---
325 return;
326
327fail:
328
329 nxt_h1p_conn_close(task, c, h1p);
330}
331
332

--- 687 unchanged lines hidden ---