Skip to content

Conversation

@hongzhidao
Copy link
Contributor

No description provided.

@hongzhidao hongzhidao force-pushed the js-fetch-http branch 3 times, most recently from 5b31cac to 499cc44 Compare April 21, 2025 17:23
@hongzhidao hongzhidao requested a review from xeioex April 30, 2025 00:39
Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetch: expose ngx_js_http_trim() and ngx_js_check_header_name().
can be merged into Fetch: separated ngx_js_http_* from ngx_js_fetch_*.



ngx_int_t
ngx_njs_string(njs_vm_t *vm, njs_value_t *value, ngx_str_t *str)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of introducing ngx_njs_string(), we should make ngx_js_string() with that prototype, which accepts ngx_str_t *str. and fix the code globally in nginx/*.

str.start = request.method.data;
str.length = request.method.len;

http->header_only = njs_strstr_eq(&str, &njs_str_value("HEAD"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe

 if (request.method.len == 4                                                       
        && ngx_strncasecmp(request.method.data, (u_char *) "HEAD", 4) == 0)           
    {                                                                                 
        http->header_only = 1;                                                        
    }

str.length = request->method.len;

for (m = &forbidden[0]; m->length != 0; m++) {
if (njs_strstr_case_eq(&request->method, m)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go this route with eliminating njs_str_t we should avoid here njs_strstr_case_eq() and njs_str_t .
Need to be fixed here and below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could introduce in ngx_js.h something like

#define
ngx_js_strstr_case_eq(s1, s2)                                                    \      
    (((s1)->len == (s2)->len)                                           \      
     && (ngx_strncasecmp((s1)->start, (s2)->start, (s1)->length) == 0))  

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Dmitry,
I feel the string-related APIs have room for improvement, and the same for mem pool.
Ieally, there is something like ngx_js_str_t, ngx_js_mp_t, and they are related APIs around them.
It's just a draft idea.

Copy link
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetch: expose ngx_js_http_trim() and ngx_js_check_header_name().
can be merged into Fetch: separated ngx_js_http_* from ngx_js_fetch_*.

@hongzhidao
Copy link
Contributor Author

hongzhidao commented May 6, 2025

Hi Dmitry,
Could we only review the PR #891, which contains this PR?
If it makes sense, we can close this one.

@xeioex
Copy link
Contributor

xeioex commented May 6, 2025

@hongzhidao

Agree. we can close this one.

@xeioex xeioex closed this May 6, 2025
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

Successfully merging this pull request may close these issues.

2 participants