nxt_http_source.c (1:fdc027c56872) nxt_http_source.c (65:10688b89aa16)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

45
46void
47nxt_http_source_handler(nxt_task_t *task, nxt_upstream_source_t *us,
48 nxt_http_source_request_create_t request_create)
49{
50 nxt_http_source_t *hs;
51 nxt_stream_source_t *stream;
52
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

45
46void
47nxt_http_source_handler(nxt_task_t *task, nxt_upstream_source_t *us,
48 nxt_http_source_request_create_t request_create)
49{
50 nxt_http_source_t *hs;
51 nxt_stream_source_t *stream;
52
53 hs = nxt_mem_zalloc(us->buffers.mem_pool, sizeof(nxt_http_source_t));
53 hs = nxt_mp_zget(us->buffers.mem_pool, sizeof(nxt_http_source_t));
54 if (nxt_slow_path(hs == NULL)) {
55 goto fail;
56 }
57
58 us->protocol_source = hs;
59
60 hs->header_in.list = nxt_list_create(us->buffers.mem_pool, 8,
61 sizeof(nxt_name_value_t));
62 if (nxt_slow_path(hs->header_in.list == NULL)) {
63 goto fail;
64 }
65
66 hs->header_in.hash = us->header_hash;
67 hs->upstream = us;
68 hs->request_create = request_create;
69
70 stream = us->stream;
71
72 if (stream == NULL) {
54 if (nxt_slow_path(hs == NULL)) {
55 goto fail;
56 }
57
58 us->protocol_source = hs;
59
60 hs->header_in.list = nxt_list_create(us->buffers.mem_pool, 8,
61 sizeof(nxt_name_value_t));
62 if (nxt_slow_path(hs->header_in.list == NULL)) {
63 goto fail;
64 }
65
66 hs->header_in.hash = us->header_hash;
67 hs->upstream = us;
68 hs->request_create = request_create;
69
70 stream = us->stream;
71
72 if (stream == NULL) {
73 stream = nxt_mem_zalloc(us->buffers.mem_pool,
74 sizeof(nxt_stream_source_t));
73 stream = nxt_mp_zget(us->buffers.mem_pool, sizeof(nxt_stream_source_t));
75 if (nxt_slow_path(stream == NULL)) {
76 goto fail;
77 }
78
79 us->stream = stream;
80 stream->upstream = us;
81
82 } else {

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

377 nxt_upstream_name_value("content-length") },
378
379 { nxt_http_source_transfer_encoding,
380 nxt_upstream_name_value("transfer-encoding") },
381};
382
383
384nxt_int_t
74 if (nxt_slow_path(stream == NULL)) {
75 goto fail;
76 }
77
78 us->stream = stream;
79 stream->upstream = us;
80
81 } else {

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

376 nxt_upstream_name_value("content-length") },
377
378 { nxt_http_source_transfer_encoding,
379 nxt_upstream_name_value("transfer-encoding") },
380};
381
382
383nxt_int_t
385nxt_http_source_hash_create(nxt_mem_pool_t *mp, nxt_lvlhsh_t *lh)
384nxt_http_source_hash_create(nxt_mp_t *mp, nxt_lvlhsh_t *lh)
386{
387 return nxt_upstream_header_hash_add(mp, lh, nxt_http_source_headers,
388 nxt_nitems(nxt_http_source_headers));
389}
390
391
392static nxt_int_t
393nxt_http_source_content_length(nxt_upstream_source_t *us, nxt_name_value_t *nv)

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

439
440 for (b = us->stream->out; b != NULL; b = b->next) {
441 nxt_buf_pool_free(&us->buffers, b);
442 }
443
444 if (nxt_fast_path(nxt_buf_pool_available(&us->buffers))) {
445
446 if (hs->chunked) {
385{
386 return nxt_upstream_header_hash_add(mp, lh, nxt_http_source_headers,
387 nxt_nitems(nxt_http_source_headers));
388}
389
390
391static nxt_int_t
392nxt_http_source_content_length(nxt_upstream_source_t *us, nxt_name_value_t *nv)

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

438
439 for (b = us->stream->out; b != NULL; b = b->next) {
440 nxt_buf_pool_free(&us->buffers, b);
441 }
442
443 if (nxt_fast_path(nxt_buf_pool_available(&us->buffers))) {
444
445 if (hs->chunked) {
447 hsc = nxt_mem_zalloc(hs->upstream->buffers.mem_pool,
448 sizeof(nxt_http_source_chunk_t));
446 hsc = nxt_mp_zalloc(hs->upstream->buffers.mem_pool,
447 sizeof(nxt_http_source_chunk_t));
449 if (nxt_slow_path(hsc == NULL)) {
450 goto fail;
451 }
452
453 /*
454 * Change the HTTP source filter chain:
455 * stream source | chunk filter | HTTP body filter
456 */

--- 174 unchanged lines hidden ---
448 if (nxt_slow_path(hsc == NULL)) {
449 goto fail;
450 }
451
452 /*
453 * Change the HTTP source filter chain:
454 * stream source | chunk filter | HTTP body filter
455 */

--- 174 unchanged lines hidden ---