nxt_h1proto.c (1709:1fe93c17d23f) nxt_h1proto.c (1732:61c7915b5b6a)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

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

1146 nxt_string("HTTP/1.1 410 Gone\r\n"),
1147 nxt_string("HTTP/1.1 411 Length Required\r\n"),
1148 nxt_string("HTTP/1.1 412 Precondition Failed\r\n"),
1149 nxt_string("HTTP/1.1 413 Payload Too Large\r\n"),
1150 nxt_string("HTTP/1.1 414 URI Too Long\r\n"),
1151 nxt_string("HTTP/1.1 415 Unsupported Media Type\r\n"),
1152 nxt_string("HTTP/1.1 416 Range Not Satisfiable\r\n"),
1153 nxt_string("HTTP/1.1 417 Expectation Failed\r\n"),
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

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

1146 nxt_string("HTTP/1.1 410 Gone\r\n"),
1147 nxt_string("HTTP/1.1 411 Length Required\r\n"),
1148 nxt_string("HTTP/1.1 412 Precondition Failed\r\n"),
1149 nxt_string("HTTP/1.1 413 Payload Too Large\r\n"),
1150 nxt_string("HTTP/1.1 414 URI Too Long\r\n"),
1151 nxt_string("HTTP/1.1 415 Unsupported Media Type\r\n"),
1152 nxt_string("HTTP/1.1 416 Range Not Satisfiable\r\n"),
1153 nxt_string("HTTP/1.1 417 Expectation Failed\r\n"),
1154 nxt_string("HTTP/1.1 418\r\n"),
1155 nxt_string("HTTP/1.1 419\r\n"),
1156 nxt_string("HTTP/1.1 420\r\n"),
1157 nxt_string("HTTP/1.1 421\r\n"),
1158 nxt_string("HTTP/1.1 422\r\n"),
1159 nxt_string("HTTP/1.1 423\r\n"),
1160 nxt_string("HTTP/1.1 424\r\n"),
1161 nxt_string("HTTP/1.1 425\r\n"),
1154 nxt_string("HTTP/1.1 418 I'm a teapot\r\n"),
1155 nxt_string("HTTP/1.1 419 \r\n"),
1156 nxt_string("HTTP/1.1 420 \r\n"),
1157 nxt_string("HTTP/1.1 421 Misdirected Request\r\n"),
1158 nxt_string("HTTP/1.1 422 Unprocessable Entity\r\n"),
1159 nxt_string("HTTP/1.1 423 Locked\r\n"),
1160 nxt_string("HTTP/1.1 424 Failed Dependency\r\n"),
1161 nxt_string("HTTP/1.1 425 \r\n"),
1162 nxt_string("HTTP/1.1 426 Upgrade Required\r\n"),
1162 nxt_string("HTTP/1.1 426 Upgrade Required\r\n"),
1163 nxt_string("HTTP/1.1 427\r\n"),
1164 nxt_string("HTTP/1.1 428\r\n"),
1165 nxt_string("HTTP/1.1 429\r\n"),
1166 nxt_string("HTTP/1.1 430\r\n"),
1163 nxt_string("HTTP/1.1 427 \r\n"),
1164 nxt_string("HTTP/1.1 428 \r\n"),
1165 nxt_string("HTTP/1.1 429 \r\n"),
1166 nxt_string("HTTP/1.1 430 \r\n"),
1167 nxt_string("HTTP/1.1 431 Request Header Fields Too Large\r\n"),
1168};
1169
1170
1171#define NXT_HTTP_LAST_NGINX_ERROR \
1172 (NXT_HTTP_TO_HTTPS + nxt_nitems(nxt_http_nginx_error) - 1)
1173
1174static const nxt_str_t nxt_http_nginx_error[] = {

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

1185 nxt_string("HTTP/1.1 501 Not Implemented\r\n"),
1186 nxt_string("HTTP/1.1 502 Bad Gateway\r\n"),
1187 nxt_string("HTTP/1.1 503 Service Unavailable\r\n"),
1188 nxt_string("HTTP/1.1 504 Gateway Timeout\r\n"),
1189 nxt_string("HTTP/1.1 505 HTTP Version Not Supported\r\n"),
1190};
1191
1192
1167 nxt_string("HTTP/1.1 431 Request Header Fields Too Large\r\n"),
1168};
1169
1170
1171#define NXT_HTTP_LAST_NGINX_ERROR \
1172 (NXT_HTTP_TO_HTTPS + nxt_nitems(nxt_http_nginx_error) - 1)
1173
1174static const nxt_str_t nxt_http_nginx_error[] = {

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

1185 nxt_string("HTTP/1.1 501 Not Implemented\r\n"),
1186 nxt_string("HTTP/1.1 502 Bad Gateway\r\n"),
1187 nxt_string("HTTP/1.1 503 Service Unavailable\r\n"),
1188 nxt_string("HTTP/1.1 504 Gateway Timeout\r\n"),
1189 nxt_string("HTTP/1.1 505 HTTP Version Not Supported\r\n"),
1190};
1191
1192
1193#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 65536\r\n")
1193#define UNKNOWN_STATUS_LENGTH nxt_length("HTTP/1.1 999 \r\n")
1194
1195static void
1196nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
1197 nxt_work_handler_t body_handler, void *data)
1198{
1199 u_char *p;
1200 size_t size;
1201 nxt_buf_t *header;

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

1243 } else if (n >= NXT_HTTP_TO_HTTPS && n <= NXT_HTTP_LAST_NGINX_ERROR) {
1244 status = &nxt_http_nginx_error[n - NXT_HTTP_TO_HTTPS];
1245
1246 } else if (n >= NXT_HTTP_INTERNAL_SERVER_ERROR
1247 && n <= NXT_HTTP_LAST_SERVER_ERROR)
1248 {
1249 status = &nxt_http_server_error[n - NXT_HTTP_INTERNAL_SERVER_ERROR];
1250
1194
1195static void
1196nxt_h1p_request_header_send(nxt_task_t *task, nxt_http_request_t *r,
1197 nxt_work_handler_t body_handler, void *data)
1198{
1199 u_char *p;
1200 size_t size;
1201 nxt_buf_t *header;

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

1243 } else if (n >= NXT_HTTP_TO_HTTPS && n <= NXT_HTTP_LAST_NGINX_ERROR) {
1244 status = &nxt_http_nginx_error[n - NXT_HTTP_TO_HTTPS];
1245
1246 } else if (n >= NXT_HTTP_INTERNAL_SERVER_ERROR
1247 && n <= NXT_HTTP_LAST_SERVER_ERROR)
1248 {
1249 status = &nxt_http_server_error[n - NXT_HTTP_INTERNAL_SERVER_ERROR];
1250
1251 } else {
1252 p = nxt_sprintf(buf, buf + UNKNOWN_STATUS_LENGTH,
1253 "HTTP/1.1 %03d\r\n", n);
1251 } else if (n <= NXT_HTTP_STATUS_MAX) {
1252 (void) nxt_sprintf(buf, buf + UNKNOWN_STATUS_LENGTH,
1253 "HTTP/1.1 %03d \r\n", n);
1254
1254
1255 unknown_status.length = p - buf;
1255 unknown_status.length = UNKNOWN_STATUS_LENGTH;
1256 unknown_status.start = buf;
1257 status = &unknown_status;
1256 unknown_status.start = buf;
1257 status = &unknown_status;
1258
1259 } else {
1260 status = &nxt_http_server_error[0];
1258 }
1259
1260 size = status->length;
1261 /* Trailing CRLF at the end of header. */
1262 size += nxt_length("\r\n");
1263
1264 conn = -1;
1265

--- 1607 unchanged lines hidden ---
1261 }
1262
1263 size = status->length;
1264 /* Trailing CRLF at the end of header. */
1265 size += nxt_length("\r\n");
1266
1267 conn = -1;
1268

--- 1607 unchanged lines hidden ---