You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying using njs to add Link header to enable dynamic http2 server push
// This code is based on the official example in http://nginx.org/en/docs/http/ngx_http_js_module.htmlif(r.headersIn.cookie){s+="Cookies:\n";varcookies=parse(r.headersIn.cookie);// https://github.com/jshttp/cookie/blob/master/index.js#L49for(varcincookies){s+=" cookie '"+c+"' is '"+cookies[c]+"'\n";r.headersOut.link='</api/'+cookies[c]+'/test>; rel=preload; as=fetch; crossorigin';}}
Which results in
$ nghttp -vs 'https://test.eoitek.net/summary' -H'cookie: a=1' 日 6/24 12:07:18 2018
[ERROR] Could not connect to the address ::1
Trying next address 127.0.0.1
[ 0.009] Connected
The negotiated protocol: h2
[ 0.011] recv SETTINGS frame <length=18, flags=0x00, stream_id=0>
(niv=3)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):128]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65536]
[SETTINGS_MAX_FRAME_SIZE(0x05):16777215]
[ 0.012] recv WINDOW_UPDATE frame <length=4, flags=0x00, stream_id=0>
(window_size_increment=2147418112)
[ 0.012] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
(niv=2)
[SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
[SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[ 0.012] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
(dep_stream_id=0, weight=201, exclusive=0)
[ 0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
(dep_stream_id=0, weight=101, exclusive=0)
[ 0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
(dep_stream_id=0, weight=1, exclusive=0)
[ 0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
(dep_stream_id=7, weight=1, exclusive=0)
[ 0.012] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
(dep_stream_id=3, weight=1, exclusive=0)
[ 0.012] send HEADERS frame <length=50, flags=0x25, stream_id=13>
; END_STREAM | END_HEADERS | PRIORITY
(padlen=0, dep_stream_id=11, weight=16, exclusive=0)
; Open new stream
:method: GET
:path: /summary
:scheme: https
:authority: test.eoitek.net
accept: */*
accept-encoding: gzip, deflate
user-agent: nghttp2/1.32.0
cookie: a=1
[ 0.012] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
; ACK
(niv=0)
[ 0.012] recv (stream_id=13) :status: 200
[ 0.012] recv (stream_id=13) server: nginx/1.15.0
[ 0.012] recv (stream_id=13) date: Sun, 24 Jun 2018 04:08:06 GMT
[ 0.012] recv (stream_id=13) content-type: text/plain
[ 0.012] recv (stream_id=13) content-length: 327
[ 0.012] recv (stream_id=13) link: </api/1/test>; rel=preload; as=fetch; crossorigin
[ 0.012] recv HEADERS frame <length=124, flags=0x04, stream_id=13>
; END_HEADERS
(padlen=0)
; First response header
JS summary
Method: GET
HTTP version: 1.1
Host: test.eoitek.net
Remote Address: 127.0.0.1
URI: /summary
Headers:
header 'host' is 'test.eoitek.net'
header 'accept' is '*/*'
header 'accept-encoding' is 'gzip, deflate'
header 'user-agent' is 'nghttp2/1.32.0'
header 'cookie' is 'a=1'
Cookies:
cookie 'a' is '1'
Args:
[ 0.012] recv DATA frame <length=327, flags=0x01, stream_id=13>
; END_STREAM
[ 0.012] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
(last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])
***** Statistics *****
Request timing:
responseEnd: the time when last byte of response was received
relative to connectEnd
requestStart: the time just before first byte of request was sent
relative to connectEnd. If '*' is shown, this was
pushed by server.
process: responseEnd - requestStart
code: HTTP status code
size: number of bytes received as response body without
inflation.
URI: request URI
see http://www.w3.org/TR/resource-timing/#processing-model
sorted by 'complete'
id responseEnd requestStart process code size request path
13 +855us +238us 616us 200 327 /summary
The response header Link is added but no PUSH_PROMISE is given. I've set http2_push_preload on; and have tested add_header "Link ...", which works fine.
The text was updated successfully, but these errors were encountered:
The Link (a well as a couple of others) header should be treated in a special way inside nginx internal headers structure to work properly. Will be fixed soon.
@xeioex Could I push resources directly in njs without Link headers ( like http2_push url )? Sometimes browsers won't use pushed resources with Link headers for unknown reason
I am trying using njs to add
Link
header to enable dynamic http2 server pushWhich results in
The response header
Link
is added but no PUSH_PROMISE is given. I've sethttp2_push_preload on;
and have testedadd_header "Link ..."
, which works fine.The text was updated successfully, but these errors were encountered: