-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use Nginx core function in ngx_http_lua_rebase_path #835
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
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 |
---|---|---|
|
@@ -371,40 +371,29 @@ ngx_http_lua_del_thread(ngx_http_request_t *r, lua_State *L, | |
u_char * | ||
ngx_http_lua_rebase_path(ngx_pool_t *pool, u_char *src, size_t len) | ||
{ | ||
u_char *p, *dst; | ||
|
||
if (len == 0) { | ||
ngx_str_t nsrc; | ||
u_char *optr; | ||
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: identifiers of local variable declarations must be aligned up (see other similar places in the existing code base). |
||
|
||
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. Extra spaces in this empty line (and also all the empty lines below). |
||
if (len == 0) | ||
return NULL; | ||
} | ||
|
||
if (src[0] == '/') { | ||
/* being an absolute path already */ | ||
dst = ngx_palloc(pool, len + 1); | ||
if (dst == NULL) { | ||
return NULL; | ||
} | ||
|
||
p = ngx_copy(dst, src, len); | ||
|
||
*p = '\0'; | ||
|
||
return dst; | ||
} | ||
|
||
dst = ngx_palloc(pool, ngx_cycle->prefix.len + len + 1); | ||
if (dst == NULL) { | ||
|
||
nsrc.len = len; | ||
nsrc.data = ngx_palloc(pool, len+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.
|
||
|
||
if (!nsrc.data) | ||
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: we always require curly braces for statement's code blocks. 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 think testing against |
||
return NULL; | ||
} | ||
|
||
p = ngx_copy(dst, ngx_cycle->prefix.data, ngx_cycle->prefix.len); | ||
p = ngx_copy(p, src, len); | ||
|
||
*p = '\0'; | ||
|
||
return dst; | ||
|
||
optr = ngx_copy(nsrc.data, src, len); | ||
*optr = '\0'; | ||
|
||
if(ngx_get_full_name(pool, (ngx_str_t*)&ngx_cycle->prefix, &nsrc)) | ||
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. Need a space after 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. Also need curly braces for the if statement body. |
||
return NULL; | ||
return nsrc.data; | ||
} | ||
|
||
|
||
|
||
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. Why the extra blank line here? |
||
ngx_int_t | ||
ngx_http_lua_send_header_if_needed(ngx_http_request_t *r, | ||
ngx_http_lua_ctx_t *ctx) | ||
|
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.
nsrc
is not a good name since then
prefix reminds me ofnumber
. But it's actually a string.