Skip to content

send early hints - #1767

Merged
i110 merged 8 commits into
masterfrom
i110/send-informational
Jun 29, 2018
Merged

send early hints#1767
i110 merged 8 commits into
masterfrom
i110/send-informational

Conversation

@i110

@i110 i110 commented May 28, 2018

Copy link
Copy Markdown
Contributor

This PR does 2 things:

  1. makes headers directives with when: early send 103 response before dispatching to the next handler
paths:
  /:
    headers.add:
      header:
        - "link: </index.js>; rel=preload"
        - "link: </style.css>; rel=preload"
      when: early
    file.dir: /path/to/doc_root
  1. with mruby, adds env['rack.early_hints']
paths:
  /:
    mruby.handler: |
      proc {|env|
        env['rack.early_hints'].call({'link' => "</index.js>; rel=preload\n</style.css>; rel=preload"})
        sleep 1
        [200, {}, ["hello"]]
      }

Comment thread lib/handler/mruby.c Outdated
if (found == NULL)
found = end;
h2o_add_header_by_str(&generator->req->pool, &generator->req->res.headers, RSTRING_PTR(name), RSTRING_LEN(name), 1, NULL,
pos, found - pos);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Am I correct in assuming that we already have code that handles \n for final responses? If yes, is the logic same as that for the final response? Is there a reason for not sharing the code?

Also, I believe that removing \n might be the correct solution here, see RFC 7230 section 3.2.4.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kazuho Thank you for the comment. I fixed it at e5f3a7b

Also, I believe that removing \n might be the correct solution here, see RFC 7230 section 3.2.4.

In Ruby web frameworks, \n is widely used to indicate the frameworks to send multiple headers with a same name at once.

@kazuho

kazuho commented Jun 18, 2018

Copy link
Copy Markdown
Member

LGTM.

@kazuho

kazuho commented Jun 29, 2018

Copy link
Copy Markdown
Member

@i110 Do you have any open issues regarding this PR? If not, please merge, then compose a new PR that updates the documentation. Thank you in advance.

@i110
i110 merged commit a3a0260 into master Jun 29, 2018
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