Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
yyamano opened this issue Nov 29, 2018 · 3 comments
Open

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

yyamano opened this issue Nov 29, 2018 · 3 comments

Comments

@yyamano
Copy link
Collaborator

yyamano commented Nov 29, 2018

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);
@matsumotory
Copy link
Owner

Thank you for your opinion. Do you have ideas about names?

@yyamano
Copy link
Collaborator Author

yyamano commented Nov 29, 2018

@matsumotory Can you give me some time to think about it?

I'm have been improving docs/class_and_method/README.md on https://github.com/yyamano/ngx_mruby/blob/doc-improvement/docs/class_and_method/README.md and playing with unfamiliar methods.
I'd like to get a clear picture before renaming.

@matsumotory
Copy link
Owner

Yes! Thanks always.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants