Skip to content

HTTP/2 with location.capture() re-enable #2243

@oowl

Description

@oowl

I have tried to reproduce #1195 (comment) mentioned bug by revert 3078ca6 commit

user root;
worker_rlimit_core 500M;

events {
    worker_connections 1024;
}

http {
    log_format compression '$remote_addr - $remote_user [$time_local] '
                        '"$request" $status $bytes_sent '
                        '"$http_referer" "$http_user_agent" "$gzip_ratio"';
    access_log logs/access.log compression;
            proxy_cache_path /tmp/nginx/cache keys_zone=api_key:10m;
    server {
        listen 8080 http2;
        location /main2 {
            content_by_lua '
                local res2 = ngx.location.capture("/internal/api",  {
                    method = ngx.HTTP_POST,
                    body = body,
                    args = {hello = "world"}
                })
                ngx.say(res2.body)
            ';
        }
        location /foo {
            echo -n world;
        }
        location /bar {
            echo -n ' people';
        }
        location = /internal/api {
            internal;
            proxy_method GET;
            proxy_cache_methods GET HEAD POST;
            proxy_cache_valid any 5m;
            proxy_cache api_key;
            proxy_cache_key api_$args;
            proxy_pass https://httpbin.org/anything;
        }
    }
}
curl --http2-prior-knowledge 127.0.0.1:8080/main2/api\?a=1  -H "accept: application/json" -X POST -vv
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080
* [HTTP/2] [1] OPENED stream for http://127.0.0.1:8080/main2/api?a=1
* [HTTP/2] [1] [:method: POST]
* [HTTP/2] [1] [:scheme: http]
* [HTTP/2] [1] [:authority: 127.0.0.1:8080]
* [HTTP/2] [1] [:path: /main2/api?a=1]
* [HTTP/2] [1] [user-agent: curl/8.4.0]
* [HTTP/2] [1] [accept: application/json]
> POST /main2/api?a=1 HTTP/2
> Host: 127.0.0.1:8080
> User-Agent: curl/8.4.0
> accept: application/json
> 
< HTTP/2 200 
< server: openresty/1.21.4.2
< date: Thu, 19 Oct 2023 15:32:30 GMT
< content-type: text/plain
< 
{
  "args": {
    "hello": "world"
  }, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/8.4.0", 
    "X-Amzn-Trace-Id": "Root=1-65314b87-0647d43721dc60d564c46b16"
  }, 
  "json": null, 
  "method": "GET", 
  "url": "https://httpbin.org/anything?hello=world"
}


curl --http2-prior-knowledge 127.0.0.1:8080/main2/api\?a=1  -H "accept: application/json" -X POST -vv
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080
* [HTTP/2] [1] OPENED stream for http://127.0.0.1:8080/main2/api?a=1
* [HTTP/2] [1] [:method: POST]
* [HTTP/2] [1] [:scheme: http]
* [HTTP/2] [1] [:authority: 127.0.0.1:8080]
* [HTTP/2] [1] [:path: /main2/api?a=1]
* [HTTP/2] [1] [user-agent: curl/8.4.0]
* [HTTP/2] [1] [accept: application/json]
> POST /main2/api?a=1 HTTP/2
> Host: 127.0.0.1:8080
> User-Agent: curl/8.4.0
> accept: application/json
> 
< HTTP/2 200 
< server: openresty/1.21.4.2
< date: Thu, 19 Oct 2023 15:36:08 GMT
< content-type: text/plain
< 
{
  "args": {
    "hello": "world"
  }, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "curl/8.4.0", 
    "X-Amzn-Trace-Id": "Root=1-65314ce8-504043c862ceaf6a48dbe6ce"
  }, 
  "json": null, 
  "method": "GET", 
  "url": "https://httpbin.org/anything?hello=world"
}

I can not reproduce this problem, Just wanted to know if it's possible to revert the 3078ca6 commit to enable HTTP2 location.capture() support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions