-
Notifications
You must be signed in to change notification settings - Fork 2.1k
integrate response content-type's expected value #936
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
Changes from all commits
2a58176
649d76b
08abbe1
e00381a
1fa6eb7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -444,6 +444,8 @@ ngx_http_lua_ngx_resp_get_headers(lua_State *L) | |
ngx_list_part_t *part; | ||
ngx_table_elt_t *header; | ||
ngx_http_request_t *r; | ||
ngx_http_lua_ctx_t *ctx; | ||
ngx_int_t rc; | ||
u_char *lowcase_key = NULL; | ||
size_t lowcase_key_sz = 0; | ||
ngx_uint_t i; | ||
|
@@ -475,6 +477,22 @@ ngx_http_lua_ngx_resp_get_headers(lua_State *L) | |
return luaL_error(L, "no request object found"); | ||
} | ||
|
||
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module); | ||
if (ctx == NULL) { | ||
return luaL_error(L, "no ctx found"); | ||
} | ||
|
||
if (!ctx->headers_set) { | ||
rc = ngx_http_lua_set_content_type(r); | ||
if (rc != NGX_OK) { | ||
return luaL_error(L, | ||
"failed to set default content type: %d", | ||
(int) rc); | ||
} | ||
|
||
ctx->headers_set = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Style: need a blank line after |
||
} | ||
|
||
ngx_http_lua_check_fake_request(L, r); | ||
|
||
part = &r->headers_out.headers.part; | ||
|
@@ -603,12 +621,19 @@ ngx_http_lua_ngx_header_get(lua_State *L) | |
ngx_uint_t i; | ||
size_t len; | ||
ngx_http_lua_loc_conf_t *llcf; | ||
ngx_http_lua_ctx_t *ctx; | ||
ngx_int_t rc; | ||
|
||
r = ngx_http_lua_get_req(L); | ||
if (r == NULL) { | ||
return luaL_error(L, "no request object found"); | ||
} | ||
|
||
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module); | ||
if (ctx == NULL) { | ||
return luaL_error(L, "no ctx found"); | ||
} | ||
|
||
ngx_http_lua_check_fake_request(L, r); | ||
|
||
/* we skip the first argument that is the table */ | ||
|
@@ -640,6 +665,17 @@ ngx_http_lua_ngx_header_get(lua_State *L) | |
|
||
key.len = len; | ||
|
||
if (!ctx->headers_set) { | ||
rc = ngx_http_lua_set_content_type(r); | ||
if (rc != NGX_OK) { | ||
return luaL_error(L, | ||
"failed to set default content type: %d", | ||
(int) rc); | ||
} | ||
|
||
ctx->headers_set = 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm afraid this is wrong here, better remove this line, like this case local content_type = ngx.header.content_type
ngx.header.foo = "foo" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, it's my mistake, just forgot it:) |
||
} | ||
|
||
return ngx_http_lua_get_output_header(L, r, &key); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line has trailing spaces. Better use the
ngx-releng
tool to check such things. For this case,ngx-releng
reports the following error (the error message was actually in red):