Deleted
Added
nxt_h1proto.c (683:5c7dd85fabd5) | nxt_h1proto.c (703:2d536dde84d2) |
---|---|
1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_router.h> 8#include <nxt_http.h> --- 693 unchanged lines hidden (view full) --- 702 nxt_string("HTTP/1.1 501 Not Implemented\r\n"), 703 nxt_string("HTTP/1.1 502 Bad Gateway\r\n"), 704 nxt_string("HTTP/1.1 503 Service Unavailable\r\n"), 705 nxt_string("HTTP/1.1 504 Gateway Timeout\r\n"), 706 nxt_string("HTTP/1.1 505 HTTP Version Not Supported\r\n"), 707}; 708 709 | 1 2/* 3 * Copyright (C) Igor Sysoev 4 * Copyright (C) NGINX, Inc. 5 */ 6 7#include <nxt_router.h> 8#include <nxt_http.h> --- 693 unchanged lines hidden (view full) --- 702 nxt_string("HTTP/1.1 501 Not Implemented\r\n"), 703 nxt_string("HTTP/1.1 502 Bad Gateway\r\n"), 704 nxt_string("HTTP/1.1 503 Service Unavailable\r\n"), 705 nxt_string("HTTP/1.1 504 Gateway Timeout\r\n"), 706 nxt_string("HTTP/1.1 505 HTTP Version Not Supported\r\n"), 707}; 708 709 |
710#define UNKNOWN_STATUS_LENGTH (sizeof("HTTP/1.1 65536\r\n") - 1) | 710#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 65536\r\n") |
711 712static void 713nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) 714{ 715 u_char *p; 716 size_t size; 717 nxt_buf_t *header; 718 nxt_str_t unknown_status; --- 42 unchanged lines hidden (view full) --- 761 762 unknown_status.length = p - buf; 763 unknown_status.start = buf; 764 status = &unknown_status; 765 } 766 767 size = status->length; 768 /* Trailing CRLF at the end of header. */ | 711 712static void 713nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r) 714{ 715 u_char *p; 716 size_t size; 717 nxt_buf_t *header; 718 nxt_str_t unknown_status; --- 42 unchanged lines hidden (view full) --- 761 762 unknown_status.length = p - buf; 763 unknown_status.start = buf; 764 status = &unknown_status; 765 } 766 767 size = status->length; 768 /* Trailing CRLF at the end of header. */ |
769 size += sizeof("\r\n") - 1; | 769 size += nxt_length("\r\n"); |
770 771 http11 = (h1p->parser.version.s.minor != '0'); 772 773 if (r->resp.content_length == NULL || r->resp.content_length->skip) { 774 if (http11) { 775 h1p->chunked = 1; | 770 771 http11 = (h1p->parser.version.s.minor != '0'); 772 773 if (r->resp.content_length == NULL || r->resp.content_length->skip) { 774 if (http11) { 775 h1p->chunked = 1; |
776 size += sizeof(chunked) - 1; | 776 size += nxt_length(chunked); |
777 /* Trailing CRLF will be added by the first chunk header. */ | 777 /* Trailing CRLF will be added by the first chunk header. */ |
778 size -= sizeof("\r\n") - 1; | 778 size -= nxt_length("\r\n"); |
779 780 } else { 781 h1p->keepalive = 0; 782 } 783 } 784 785 conn = -1; 786 787 if (http11 ^ h1p->keepalive) { 788 conn = h1p->keepalive; 789 size += connection[conn].length; 790 } 791 792 nxt_list_each(field, r->resp.fields) { 793 794 if (!field->skip) { 795 size += field->name_length + field->value_length; | 779 780 } else { 781 h1p->keepalive = 0; 782 } 783 } 784 785 conn = -1; 786 787 if (http11 ^ h1p->keepalive) { 788 conn = h1p->keepalive; 789 size += connection[conn].length; 790 } 791 792 nxt_list_each(field, r->resp.fields) { 793 794 if (!field->skip) { 795 size += field->name_length + field->value_length; |
796 size += sizeof(": \r\n") - 1; | 796 size += nxt_length(": \r\n"); |
797 } 798 799 } nxt_list_loop; 800 801 header = nxt_http_buf_mem(task, r, size); 802 if (nxt_slow_path(header == NULL)) { 803 nxt_h1p_request_error(task, r); 804 return; --- 14 unchanged lines hidden (view full) --- 819 820 } nxt_list_loop; 821 822 if (conn >= 0) { 823 p = nxt_cpymem(p, connection[conn].start, connection[conn].length); 824 } 825 826 if (h1p->chunked) { | 797 } 798 799 } nxt_list_loop; 800 801 header = nxt_http_buf_mem(task, r, size); 802 if (nxt_slow_path(header == NULL)) { 803 nxt_h1p_request_error(task, r); 804 return; --- 14 unchanged lines hidden (view full) --- 819 820 } nxt_list_loop; 821 822 if (conn >= 0) { 823 p = nxt_cpymem(p, connection[conn].start, connection[conn].length); 824 } 825 826 if (h1p->chunked) { |
827 p = nxt_cpymem(p, chunked, sizeof(chunked) - 1); | 827 p = nxt_cpymem(p, chunked, nxt_length(chunked)); |
828 /* Trailing CRLF will be added by the first chunk header. */ 829 830 } else { 831 *p++ = '\r'; *p++ = '\n'; 832 } 833 834 header->mem.free = p; 835 --- 56 unchanged lines hidden (view full) --- 892 893 894static nxt_buf_t * 895nxt_h1p_chunk_create(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out) 896{ 897 nxt_off_t size; 898 nxt_buf_t *b, **prev, *header, *tail; 899 | 828 /* Trailing CRLF will be added by the first chunk header. */ 829 830 } else { 831 *p++ = '\r'; *p++ = '\n'; 832 } 833 834 header->mem.free = p; 835 --- 56 unchanged lines hidden (view full) --- 892 893 894static nxt_buf_t * 895nxt_h1p_chunk_create(nxt_task_t *task, nxt_http_request_t *r, nxt_buf_t *out) 896{ 897 nxt_off_t size; 898 nxt_buf_t *b, **prev, *header, *tail; 899 |
900 const size_t chunk_size = 2 * (sizeof("\r\n") - 1) + NXT_OFF_T_HEXLEN; | 900 const size_t chunk_size = 2 * nxt_length("\r\n") + NXT_OFF_T_HEXLEN; |
901 static const char tail_chunk[] = "\r\n0\r\n\r\n"; 902 903 size = 0; 904 prev = &out; 905 906 for (b = out; b != NULL; b = b->next) { 907 908 if (nxt_buf_is_last(b)) { --- 4 unchanged lines hidden (view full) --- 913 914 *prev = tail; 915 tail->next = b; 916 /* 917 * The tail_chunk size with trailing zero is 8 bytes, so 918 * memcpy may be inlined with just single 8 byte move operation. 919 */ 920 nxt_memcpy(tail->mem.free, tail_chunk, sizeof(tail_chunk)); | 901 static const char tail_chunk[] = "\r\n0\r\n\r\n"; 902 903 size = 0; 904 prev = &out; 905 906 for (b = out; b != NULL; b = b->next) { 907 908 if (nxt_buf_is_last(b)) { --- 4 unchanged lines hidden (view full) --- 913 914 *prev = tail; 915 tail->next = b; 916 /* 917 * The tail_chunk size with trailing zero is 8 bytes, so 918 * memcpy may be inlined with just single 8 byte move operation. 919 */ 920 nxt_memcpy(tail->mem.free, tail_chunk, sizeof(tail_chunk)); |
921 tail->mem.free += sizeof(tail_chunk) - 1; | 921 tail->mem.free += nxt_length(tail_chunk); |
922 923 break; 924 } 925 926 size += nxt_buf_used_size(b); 927 prev = &b->next; 928 } 929 --- 347 unchanged lines hidden --- | 922 923 break; 924 } 925 926 size += nxt_buf_used_size(b); 927 prev = &b->next; 928 } 929 --- 347 unchanged lines hidden --- |