Skip to content
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

Add trailer support to network responses #344

Merged
merged 1 commit into from
Aug 10, 2016
Merged

Add trailer support to network responses #344

merged 1 commit into from
Aug 10, 2016

Conversation

annevk
Copy link
Member

@annevk annevk commented Jul 28, 2016

Trailer support we can add in the future if this minimal viable
solution is a success:

  • Support for synthetic responses.
  • Support for (synthetic) requests.
  • Trailer headers that have semantics.

Fixes #343 and fixes #34.

@annevk
Copy link
Member Author

annevk commented Jul 28, 2016

Paging @mnot @yutakahirano @tyoshino @louiscryan for review.

@louiscryan
Copy link

louiscryan commented Jul 28, 2016

Looks about right to me.

I wonder what folks think should be permitted in CORS. 'Trailers' is not a mandatory header and is less useful in HTTP2 than it might have been in HTTP1. 'TE: trailers' seems like it has more value however.

@annevk
Copy link
Member Author

annevk commented Jul 29, 2016

You mean for request headers? TE is forbidden at the moment. If we need to start including that I suppose this would be a bigger change and we need some kind of opt-in for that in Request (I doubt user agents would want to always include that for everything). From the discussion at the HTTP workshop that didn't seem to be necessary and the response could just include a trailer if it wanted to.

@yutakahirano
Copy link
Member

yutakahirano commented Jul 29, 2016

Ah, I didn't notice this PR when I wrote a comment at #34. Never mind.

I think you need to reject the trailer promise whenever you get an error.
Isn't "response's associated promise" a bit too general for a promise for the trailer?

@annevk annevk mentioned this pull request Jul 29, 2016
@annevk
Copy link
Member Author

annevk commented Jul 29, 2016

What kind of error are you thinking about?

@yutakahirano
Copy link
Member

Whenever a fetch is terminated after a response is received.

@wenbozhu
Copy link

Re: CORS, TE "opt-in" would be desired, as proxies may drop response trailers without such a request header (no?)

Trailer is a response header and there is no harm for the server to always include such a header with Access-Control-Expose-Headers. Discussion or spec clarification may be needed to clarify if UA needs drop trailers that are not specified with Trailer.

@annevk
Copy link
Member Author

annevk commented Jul 29, 2016

@yutakahirano I guess we could do that as it aligns with throwing an error for the body stream, but it also seems fine that trailer just returns an empty header list in that case. Hmm.

@annevk
Copy link
Member Author

annevk commented Jul 29, 2016

Addressed feedback thus far apart from TE opt-in. Not entirely sure what to do with that. Questions I have around that:

  1. If the UA did not include that opt-in can the response still contain a trailer legally?
  2. Even if it cannot contain it legally, would we still expect it to show up in the API?
  3. Should we have an opt-in or just remove the header from the list of forbidden headers? It doesn't seem like the header could be harmful same-origin or cross-origin with CORS, even with arbitrary values.

@mnot
Copy link
Member

mnot commented Jul 29, 2016

TE: trailers isn't a terribly useful signal for fetch to generate, because it doesn't tell the server whether individual headers are going to be actually processed (e.g., ETag and Last-Modified for a cache).

What it does help with is determining whether an entire path is compatible with trailers; i.e., whether or not there's a HTTP/1.0 hop. So it make sense for intermediaries to generate it when the downstream path is trailer-safe, or the intermediary buffers responses and sticks them into headers.

@annevk
Copy link
Member Author

annevk commented Jul 29, 2016

Thanks, given httpwg/http-core#18 I suggest we postpone/separate any changes around TE and land this change as-is.

@yutakahirano
Copy link
Member

When a response comes from the service worker, no fetch-response-done task is queued, right?

@annevk
Copy link
Member Author

annevk commented Aug 4, 2016

Good point. I should probably move that task queuing to "main fetch" instead somehow.

@annevk
Copy link
Member Author

annevk commented Aug 4, 2016

@yutakahirano does that apply to fetch termination as well?

@annevk
Copy link
Member Author

annevk commented Aug 4, 2016

I moved the task to main fetch. Fetch termination is something we need to sort through further and there's various issues on it already. We can take that up elsewhere.

Anything else?

@annevk
Copy link
Member Author

annevk commented Aug 5, 2016

So I forgot about two things that need to be fixed before landing: 1) Filtering for "no-cors". 2) How this works with CORS.

  1. Is easy. It'll just resolve to the empty list.

  2. Is hard. I think the easiest v1 would be to also filter it for CORS completely and later we can add a header or some such to reveal them.

@igrigorik
Copy link
Member

👍

@annevk
Copy link
Member Author

annevk commented Aug 8, 2016

As a heads up, I plan to land trailer support tomorrow. If you have concerns or would like more time, please leave a comment.

@yutakahirano
Copy link
Member

Sorry for the late response. I think Response.clone needs to create a new trailer promise.

@annevk
Copy link
Member Author

annevk commented Aug 9, 2016

Better late than too late. @domenic does the last commit look okay to you? I basically need to resolve the promise of the cloned response when the promise of the original response is fulfilled, but I should probably not reuse the Headers object even though it's immutable (so far we kept the relationships 1:1).

@annevk
Copy link
Member Author

annevk commented Aug 9, 2016

(Also, that was great feedback @yutakahirano, but you probably knew that already. 😊)

@yutakahirano
Copy link
Member

LGTM

Additional trailer support we can add in the future if this minimal
viable solution (that is nonetheless complicated) is a success:

* Support for synthetic responses.
* Support for (synthetic) requests.
* Trailer headers that have semantics.
* Support for trailer headers in CORS (only for responses I think).

Fixes #34 and fixes #343.
@annevk annevk merged commit 427255e into master Aug 10, 2016
@annevk annevk deleted the trailer branch August 10, 2016 06:12
@annevk
Copy link
Member Author

annevk commented Aug 10, 2016

Thanks everyone for the help. Now it's up to you all to get it tested and implemented. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Non-null response body check is a no-op Access to the HTTP trailer
6 participants