Welcome! Log In Create A New Profile

Advanced

Re: Logging embedded Perl return value

All files from this thread

File Name File Size   Posted by Date  
patch.any_status 8.5 KB open | download Igor Sysoev 04/10/2009 Read message
July 07, 2009 11:26PM
I tried patching nginx to produce a '210 Custom Response' which is just a 2xx
success response but without any content. As it doesn't use content I thought
it should behave like the existing HTTP_NO_CONTENT response.

Is there any problem in doing it this way? Is there a better way to add it?

diff -crB /usr/src/redhat/BUILD/nginx-0.7.61/src/http/modules/ngx_http_headers_filter_module.c nginx-0.7.61/src/http/modules/ngx_http_headers_filter_module.c
*** /usr/src/redhat/BUILD/nginx-0.7.61/src/http/modules/ngx_http_headers_filter_module.c 2009-03-26 21:34:37.000000000 +0800
--- nginx-0.7.61/src/http/modules/ngx_http_headers_filter_module.c 2009-07-08 10:25:54.000000000 +0800
***************
*** 145,150 ****
--- 145,151 ----
|| r != r->main
|| (r->headers_out.status != NGX_HTTP_OK
&& r->headers_out.status != NGX_HTTP_NO_CONTENT
+ && r->headers_out.status != NGX_HTTP_CUSTOM_RESPONSE
&& r->headers_out.status != NGX_HTTP_MOVED_PERMANENTLY
&& r->headers_out.status != NGX_HTTP_MOVED_TEMPORARILY
&& r->headers_out.status != NGX_HTTP_NOT_MODIFIED))
diff -crB /usr/src/redhat/BUILD/nginx-0.7.61/src/http/modules/perl/nginx.pm nginx-0.7.61/src/http/modules/perl/nginx.pm
*** /usr/src/redhat/BUILD/nginx-0.7.61/src/http/modules/perl/nginx.pm 2009-06-22 17:23:35.000000000 +0800
--- nginx-0.7.61/src/http/modules/perl/nginx.pm 2009-07-08 10:23:53.000000000 +0800
***************
*** 16,21 ****
--- 16,22 ----
HTTP_CREATED
HTTP_NO_CONTENT
HTTP_PARTIAL_CONTENT
+ HTTP_CUSTOM_RESPONSE

HTTP_MOVED_PERMANENTLY
HTTP_MOVED_TEMPORARILY
***************
*** 61,66 ****
--- 62,68 ----
use constant HTTP_CREATED => 201;
use constant HTTP_NO_CONTENT => 204;
use constant HTTP_PARTIAL_CONTENT => 206;
+ use constant HTTP_CUSTOM_RESPONSE => 210;

use constant HTTP_MOVED_PERMANENTLY => 301;
use constant HTTP_MOVED_TEMPORARILY => 302;
diff -crB /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_header_filter_module.c nginx-0.7.61/src/http/ngx_http_header_filter_module.c
*** /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_header_filter_module.c 2009-05-18 20:58:19.000000000 +0800
--- nginx-0.7.61/src/http/ngx_http_header_filter_module.c 2009-07-08 10:36:55.000000000 +0800
***************
*** 58,67 ****
ngx_string("204 No Content"),
ngx_null_string, /* "205 Reset Content" */
ngx_string("206 Partial Content"),

/* ngx_null_string, */ /* "207 Multi-Status" */

! #define NGX_HTTP_LAST_LEVEL_200 207
#define NGX_HTTP_LEVEL_200 (NGX_HTTP_LAST_LEVEL_200 - 200)

/* ngx_null_string, */ /* "300 Multiple Choices" */
--- 58,71 ----
ngx_string("204 No Content"),
ngx_null_string, /* "205 Reset Content" */
ngx_string("206 Partial Content"),
+ ngx_null_string,
+ ngx_null_string,
+ ngx_null_string,
+ ngx_string("210 Custom Response"),

/* ngx_null_string, */ /* "207 Multi-Status" */

! #define NGX_HTTP_LAST_LEVEL_200 211
#define NGX_HTTP_LEVEL_200 (NGX_HTTP_LAST_LEVEL_200 - 200)

/* ngx_null_string, */ /* "300 Multiple Choices" */
***************
*** 220,226 ****
{
/* 2XX */

! if (status == NGX_HTTP_NO_CONTENT) {
r->header_only = 1;
r->headers_out.content_type.len = 0;
r->headers_out.content_type.data = NULL;
--- 224,230 ----
{
/* 2XX */

! if (status == NGX_HTTP_NO_CONTENT || status == NGX_HTTP_CUSTOM_RESPONSE) {
r->header_only = 1;
r->headers_out.content_type.len = 0;
r->headers_out.content_type.data = NULL;
diff -crB /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_request.c nginx-0.7.61/src/http/ngx_http_request.c
*** /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_request.c 2009-06-22 17:31:33.000000000 +0800
--- nginx-0.7.61/src/http/ngx_http_request.c 2009-07-08 10:23:21.000000000 +0800
***************
*** 1852,1858 ****

if (rc >= NGX_HTTP_SPECIAL_RESPONSE
|| rc == NGX_HTTP_CREATED
! || rc == NGX_HTTP_NO_CONTENT)
{
if (rc == NGX_HTTP_CLOSE) {
ngx_http_close_request(r, rc);
--- 1852,1859 ----

if (rc >= NGX_HTTP_SPECIAL_RESPONSE
|| rc == NGX_HTTP_CREATED
! || rc == NGX_HTTP_NO_CONTENT
! || rc == NGX_HTTP_CUSTOM_RESPONSE)
{
if (rc == NGX_HTTP_CLOSE) {
ngx_http_close_request(r, rc);
diff -crB /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_request.h nginx-0.7.61/src/http/ngx_http_request.h
*** /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_request.h 2009-05-22 19:05:26.000000000 +0800
--- nginx-0.7.61/src/http/ngx_http_request.h 2009-07-08 10:22:48.000000000 +0800
***************
*** 67,72 ****
--- 67,74 ----
#define NGX_HTTP_NO_CONTENT 204
#define NGX_HTTP_PARTIAL_CONTENT 206

+ #define NGX_HTTP_CUSTOM_RESPONSE 210
+
#define NGX_HTTP_SPECIAL_RESPONSE 300
#define NGX_HTTP_MOVED_PERMANENTLY 301
#define NGX_HTTP_MOVED_TEMPORARILY 302
diff -crB /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_script.c nginx-0.7.61/src/http/ngx_http_script.c
*** /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_script.c 2009-04-27 19:32:33.000000000 +0800
--- nginx-0.7.61/src/http/ngx_http_script.c 2009-07-08 10:27:24.000000000 +0800
***************
*** 1281,1287 ****

e->status = code->status;

! if (code->status == NGX_HTTP_NO_CONTENT) {
e->request->header_only = 1;
e->request->zero_body = 1;
}
--- 1281,1289 ----

e->status = code->status;

! if (code->status == NGX_HTTP_NO_CONTENT
! || code->status == NGX_HTTP_CUSTOM_RESPONSE) {
!
e->request->header_only = 1;
e->request->zero_body = 1;
}
diff -crB /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_special_response.c nginx-0.7.61/src/http/ngx_http_special_response.c
*** /usr/src/redhat/BUILD/nginx-0.7.61/src/http/ngx_http_special_response.c 2009-05-25 17:06:29.000000000 +0800
--- nginx-0.7.61/src/http/ngx_http_special_response.c 2009-07-08 10:28:09.000000000 +0800
***************
*** 404,410 ****
err = 0;
r->header_only = 1;

! } else if (error == NGX_HTTP_NO_CONTENT) {
/* 204 */
err = 0;

--- 404,410 ----
err = 0;
r->header_only = 1;

! } else if (error == NGX_HTTP_NO_CONTENT || error == NGX_HTTP_CUSTOM_RESPONSE) {
/* 204 */
err = 0;
Subject Author Posted

Logging embedded Perl return value

davidc April 08, 2009 11:41PM

Re: Logging embedded Perl return value

Igor Sysoev April 09, 2009 01:16AM

Re: Logging embedded Perl return value

davidc April 09, 2009 04:54AM

Re: Logging embedded Perl return value Attachments

Igor Sysoev April 10, 2009 06:33AM

Re: Logging embedded Perl return value

davidc July 07, 2009 05:59AM

Re: Logging embedded Perl return value

davidc July 07, 2009 11:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 67
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready