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

Investigage full-duplex request/response streaming #26905

Open
gterzian opened this issue Jun 13, 2020 · 2 comments
Open

Investigage full-duplex request/response streaming #26905

gterzian opened this issue Jun 13, 2020 · 2 comments

Comments

@gterzian
Copy link
Member

@gterzian gterzian commented Jun 13, 2020

See the discussions over at whatwg/fetch#425 (comment)

The idea is, I think, that the body of a request would be transmitted over the network, and at the same time the body of the response could already be read by script as a stream.

From the linked-to discussion, it appears web developers want this, and the spec sort of allows for it(?), however current implementations have a hard time changing their networking stack model to allow for this.

I think we should be able to do it, since #25873 has landed, and I don't think there is anything in the structure of net that would prevent this.

However first we need to investigate #26904, and then I think it would be interesting to see if Servo could support full-duplex streaming.

@gterzian
Copy link
Member Author

@gterzian gterzian commented Jun 13, 2020

A few pointers:

In obtain_response, which returns a future for the actual http response, we:

  1. First setup an IPC route that will be used to receive chunks from the body from script, and transmit them over the network, at https://github.com/servo/servo/blob/73760ea59434971d24e6aac7e5fe3c79c1ba5bf6/components/net/http_loader.rs
  2. Call request on the Hyper client, to get a future for the response, at https://github.com/servo/servo/blob/73760ea59434971d24e6aac7e5fe3c79c1ba5bf6/components/net/http_loader.rs

Then later, this future is used to:

  1. Wait on it, to get the response headers, at https://github.com/servo/servo/blob/73760ea59434971d24e6aac7e5fe3c79c1ba5bf6/components/net/http_loader.rs
  2. Used to get the rest of the data at: https://github.com/servo/servo/blob/73760ea59434971d24e6aac7e5fe3c79c1ba5bf6/components/net/http_loader.rs

I guess the question is really whether Hyper gives us the headers, and data, for the response, while the request stream is still being read from...

@gterzian
Copy link
Member Author

@gterzian gterzian commented Jun 13, 2020

Looking at https://docs.rs/hyper/0.13.6/src/hyper/client/mod.rs.html#245

I have a feeling using the response future requires first completing the request feature, meaning it would not work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.