Deleted
Added
nxt_php_sapi.c (142:71cff5c3c36f) | nxt_php_sapi.c (206:86a529b2ea9b) |
---|---|
1 2/* 3 * Copyright (C) Max Romanov 4 * Copyright (C) Valentin V. Bartenev 5 * Copyright (C) NGINX, Inc. 6 */ 7 8#include "php.h" --- 114 unchanged lines hidden (view full) --- 123 124typedef struct { 125 nxt_task_t *task; 126 nxt_app_rmsg_t *rmsg; 127 nxt_app_request_t r; 128 nxt_str_t script; 129 nxt_app_wmsg_t *wmsg; 130 nxt_mp_t *mem_pool; | 1 2/* 3 * Copyright (C) Max Romanov 4 * Copyright (C) Valentin V. Bartenev 5 * Copyright (C) NGINX, Inc. 6 */ 7 8#include "php.h" --- 114 unchanged lines hidden (view full) --- 123 124typedef struct { 125 nxt_task_t *task; 126 nxt_app_rmsg_t *rmsg; 127 nxt_app_request_t r; 128 nxt_str_t script; 129 nxt_app_wmsg_t *wmsg; 130 nxt_mp_t *mem_pool; |
131 132 size_t body_preread_size; |
|
131} nxt_php_run_ctx_t; 132 133nxt_inline nxt_int_t nxt_php_write(nxt_php_run_ctx_t *ctx, 134 const u_char *data, size_t len, 135 nxt_bool_t flush, nxt_bool_t last); 136 137 138static nxt_str_t nxt_php_path; --- 198 unchanged lines hidden (view full) --- 337 NXT_READ(&h->host); 338 NXT_READ(&h->cookie); 339 NXT_READ(&h->content_type); 340 NXT_READ(&h->content_length); 341 342 RC(nxt_app_msg_read_size(task, rmsg, &s)); 343 h->parsed_content_length = s; 344 | 133} nxt_php_run_ctx_t; 134 135nxt_inline nxt_int_t nxt_php_write(nxt_php_run_ctx_t *ctx, 136 const u_char *data, size_t len, 137 nxt_bool_t flush, nxt_bool_t last); 138 139 140static nxt_str_t nxt_php_path; --- 198 unchanged lines hidden (view full) --- 339 NXT_READ(&h->host); 340 NXT_READ(&h->cookie); 341 NXT_READ(&h->content_type); 342 NXT_READ(&h->content_length); 343 344 RC(nxt_app_msg_read_size(task, rmsg, &s)); 345 h->parsed_content_length = s; 346 |
345 NXT_READ(&ctx->r.body.preread); 346 | |
347#undef NXT_READ 348#undef RC 349 350 /* Further headers read moved to nxt_php_register_variables. */ 351 return NXT_OK; 352 353fail: 354 355 return rc; 356} 357 358 359static nxt_int_t 360nxt_php_prepare_msg(nxt_task_t *task, nxt_app_request_t *r, 361 nxt_app_wmsg_t *wmsg) 362{ 363 nxt_int_t rc; | 347#undef NXT_READ 348#undef RC 349 350 /* Further headers read moved to nxt_php_register_variables. */ 351 return NXT_OK; 352 353fail: 354 355 return rc; 356} 357 358 359static nxt_int_t 360nxt_php_prepare_msg(nxt_task_t *task, nxt_app_request_t *r, 361 nxt_app_wmsg_t *wmsg) 362{ 363 nxt_int_t rc; |
364 nxt_buf_t *b; |
|
364 nxt_http_field_t *field; 365 nxt_app_request_header_t *h; 366 367 static const nxt_str_t prefix = nxt_string("HTTP_"); 368 static const nxt_str_t eof = nxt_null_string; 369 370 h = &r->header; 371 --- 36 unchanged lines hidden (view full) --- 408 409 NXT_WRITE(&h->host); 410 NXT_WRITE(&h->cookie); 411 NXT_WRITE(&h->content_type); 412 NXT_WRITE(&h->content_length); 413 414 RC(nxt_app_msg_write_size(task, wmsg, h->parsed_content_length)); 415 | 365 nxt_http_field_t *field; 366 nxt_app_request_header_t *h; 367 368 static const nxt_str_t prefix = nxt_string("HTTP_"); 369 static const nxt_str_t eof = nxt_null_string; 370 371 h = &r->header; 372 --- 36 unchanged lines hidden (view full) --- 409 410 NXT_WRITE(&h->host); 411 NXT_WRITE(&h->cookie); 412 NXT_WRITE(&h->content_type); 413 NXT_WRITE(&h->content_length); 414 415 RC(nxt_app_msg_write_size(task, wmsg, h->parsed_content_length)); 416 |
416 NXT_WRITE(&r->body.preread); 417 | |
418 nxt_list_each(field, h->fields) { 419 RC(nxt_app_msg_write_prefixed_upcase(task, wmsg, 420 &prefix, &field->name)); 421 NXT_WRITE(&field->value); 422 423 } nxt_list_loop; 424 425 /* end-of-headers mark */ 426 NXT_WRITE(&eof); 427 | 417 nxt_list_each(field, h->fields) { 418 RC(nxt_app_msg_write_prefixed_upcase(task, wmsg, 419 &prefix, &field->name)); 420 NXT_WRITE(&field->value); 421 422 } nxt_list_loop; 423 424 /* end-of-headers mark */ 425 NXT_WRITE(&eof); 426 |
427 RC(nxt_app_msg_write_size(task, wmsg, r->body.preread_size)); 428 429 for(b = r->body.buf; b != NULL; b = b->next) { 430 RC(nxt_app_msg_write_raw(task, wmsg, b->mem.pos, 431 nxt_buf_mem_used_size(&b->mem))); 432 } 433 |
|
428#undef NXT_WRITE 429#undef RC 430 431 return NXT_OK; 432 433fail: 434 435 return NXT_ERROR; --- 232 unchanged lines hidden (view full) --- 668#ifdef NXT_PHP7 669static size_t 670nxt_php_read_post(char *buffer, size_t count_bytes TSRMLS_DC) 671#else 672static int 673nxt_php_read_post(char *buffer, uint count_bytes TSRMLS_DC) 674#endif 675{ | 434#undef NXT_WRITE 435#undef RC 436 437 return NXT_OK; 438 439fail: 440 441 return NXT_ERROR; --- 232 unchanged lines hidden (view full) --- 674#ifdef NXT_PHP7 675static size_t 676nxt_php_read_post(char *buffer, size_t count_bytes TSRMLS_DC) 677#else 678static int 679nxt_php_read_post(char *buffer, uint count_bytes TSRMLS_DC) 680#endif 681{ |
676 off_t rest; 677 size_t size; 678/* 679 ssize_t n; 680 nxt_err_t err; 681 nxt_php_ctx_t *ctx; 682 nxt_app_request_t *r; 683*/ | 682 size_t size, rest; |
684 nxt_php_run_ctx_t *ctx; | 683 nxt_php_run_ctx_t *ctx; |
685 nxt_app_request_body_t *b; | |
686 nxt_app_request_header_t *h; 687 688 ctx = SG(server_context); 689 h = &ctx->r.header; | 684 nxt_app_request_header_t *h; 685 686 ctx = SG(server_context); 687 h = &ctx->r.header; |
690 b = &ctx->r.body; | |
691 | 688 |
692 rest = h->parsed_content_length - SG(read_post_bytes); | 689 rest = (size_t) h->parsed_content_length - SG(read_post_bytes); |
693 694 nxt_debug(ctx->task, "nxt_php_read_post %O", rest); 695 696 if (rest == 0) { 697 return 0; 698 } 699 | 690 691 nxt_debug(ctx->task, "nxt_php_read_post %O", rest); 692 693 if (rest == 0) { 694 return 0; 695 } 696 |
700 size = 0; 701#ifdef NXT_PHP7 702 count_bytes = (size_t) nxt_min(rest, (off_t) count_bytes); 703#else 704 count_bytes = (uint) nxt_min(rest, (off_t) count_bytes); 705#endif | 697 rest = nxt_min(ctx->body_preread_size, (size_t) count_bytes); 698 size = nxt_app_msg_read_raw(ctx->task, ctx->rmsg, buffer, rest); |
706 | 699 |
707 if (b->preread.length != 0) { 708 size = nxt_min(b->preread.length, count_bytes); | 700 ctx->body_preread_size -= size; |
709 | 701 |
710 nxt_memcpy(buffer, b->preread.start, size); 711 712 b->preread.length -= size; 713 b->preread.start += size; 714 715 if (size == count_bytes) { 716 return size; 717 } 718 } 719 720#if 0 721 nxt_debug(ctx->task, "recv %z", (size_t) count_bytes - size); 722 723 n = recv(r->event_conn->socket.fd, buffer + size, count_bytes - size, 0); 724 725 if (nxt_slow_path(n <= 0)) { 726 err = (n == 0) ? 0 : nxt_socket_errno; 727 728 nxt_log_error(NXT_LOG_ERR, r->log, "recv(%d, %uz) failed %E", 729 r->event_conn->socket.fd, (size_t) count_bytes - size, 730 err); 731 732 return size; 733 } 734 735 return size + n; 736#endif | |
737 return size; 738} 739 740 741static char * 742nxt_php_read_cookies(TSRMLS_D) 743{ 744 nxt_php_run_ctx_t *ctx; --- 118 unchanged lines hidden (view full) --- 863 rc = nxt_app_msg_read_str(task, ctx->rmsg, &v); 864 if (nxt_slow_path(rc != NXT_OK)) { 865 break; 866 } 867 868 NXT_PHP_SET(n.start, v); 869 } 870 | 702 return size; 703} 704 705 706static char * 707nxt_php_read_cookies(TSRMLS_D) 708{ 709 nxt_php_run_ctx_t *ctx; --- 118 unchanged lines hidden (view full) --- 828 rc = nxt_app_msg_read_str(task, ctx->rmsg, &v); 829 if (nxt_slow_path(rc != NXT_OK)) { 830 break; 831 } 832 833 NXT_PHP_SET(n.start, v); 834 } 835 |
836 nxt_app_msg_read_size(task, ctx->rmsg, &ctx->body_preread_size); 837 |
|
871#undef NXT_PHP_SET 872} 873 874 875static void 876nxt_php_log_message(char *message 877#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE 878 , int syslog_type_int 879#endif 880) 881{ 882 return; 883} | 838#undef NXT_PHP_SET 839} 840 841 842static void 843nxt_php_log_message(char *message 844#ifdef NXT_HAVE_PHP_LOG_MESSAGE_WITH_SYSLOG_TYPE 845 , int syslog_type_int 846#endif 847) 848{ 849 return; 850} |