Skip to content

Nginx::Request#content_type doesn't return Content-Type of request #411

@yyamano

Description

@yyamano

Nginx::Request#content_type doesn't return Content-Type of request.

It looks Nginx::Request#content_type() and Nginx::Request#content_type=() are for HTTP response, not HTTP request. Very confusing name to me.

        location /foo {
          mruby_content_handler_code '
            r = Nginx::Request.new
            Nginx.rputs "content_type: " + r.content_type
            Nginx.return Nginx::HTTP_OK
          ';
        }
% curl -v -H "Content-Type: text/plain" http://127.0.0.1:58080/foo
* About to connect() to 127.0.0.1 port 58080 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 58080 (#0)
> GET /foo HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:58080
> Accept: */*
> Content-Type: text/plain
> 
< HTTP/1.1 200 OK
< Date: Thu, 29 Nov 2018 04:53:26 GMT
< Content-Length: 14
< Connection: keep-alive
< hoge: fuga
< Server: global_ngx_mruby
< 
* Connection #0 to host 127.0.0.1 left intact

From src/http/ngx_http_mruby_request.c

NGX_MRUBY_DEFINE_METHOD_NGX_GET_REQUEST_MEMBER_STR(content_type, r->headers_out.content_type);
NGX_MRUBY_DEFINE_METHOD_NGX_SET_REQUEST_MEMBER_STR(content_type, r->headers_out.content_type);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions