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
A-networkA-testingC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
We can write full integration tests in the form of pages that run in the WPT harness and Python scripts that control the server responses, but it's not particularly efficient. At some point we're going to implement an HTTP cache, and being able to test precisely how the networking stack treats a series of HTTP requests/responses will be important. Furthermore, the improvements for testing can lay the groundwork for an implementation of request interception for a future ServiceWorker implementation!
I propose the following:
we create a new Response struct that contains all of the data used by Servo's networking stack from hyper's Response
we create a trait called HTTPResponseProvider with a method that takes in all the data associated with an HTTP request and returns the new Response type
we create an implementation called RemoteHTTPResponse that extracts all of the code from http_loader::load that initiates a network connection and waits for a response
we figure out what else makes http_loader::load difficult to test
I've done some proof-of-concept work on this over the past couple of days. I'm still debating whether the approach makes sense. The current approach:
Abstract load into two different functions, one that is responsible for performing the request and managing errors, and one that handles IPC/inter-task comms. This, at least, makes testing less complicated.
Inject the hyper::net::NetworkConnector dependency, and then mock that out (as necessary) in tests. For the proof-of-concept, I've simply copied all the HTTP1 code from hyper::mock. It's probably better to wrap this in something like what @jdm suggested, like a servo HttpRequester or something, but the current code is pretty tightly coupled to hyper at the moment.
Written two tests just to show some progress 🎁.
I've also made some simplifying assumptions for the moment, that may need to change before finishing (e.g. is nossl still an option that we care about? are all unsupported scheme errors are the same? etc)
A-networkA-testingC-assignedThere is someone working on resolving the issueE-more-complexVariable effort required; may require a mentor. Recommended solution is clearly described in the iss
Activity
jdm commentedon Jul 24, 2015
cc @samfoo does this address your concerns from #6703?
samfoo commentedon Jul 26, 2015
Yep, it's a great start.
samfoo commentedon Jul 30, 2015
Hey guys, I'll pick this up over the weekend.
jdm commentedon Jul 30, 2015
Fantastic!
Refactors http_loader::load to be synchronous w/ an async wrapper
Injects the network connector as a dependency into http_loader::load
Abstracts out initial client connection and SSL errors (which I don't…
Adds simple POC unit test for load
samfoo commentedon Aug 2, 2015
I've done some proof-of-concept work on this over the past couple of days. I'm still debating whether the approach makes sense. The current approach:
loadinto two different functions, one that is responsible for performing the request and managing errors, and one that handles IPC/inter-task comms. This, at least, makes testing less complicated.hyper::net::NetworkConnectordependency, and then mock that out (as necessary) in tests. For the proof-of-concept, I've simply copied all the HTTP1 code fromhyper::mock. It's probably better to wrap this in something like what @jdm suggested, like a servoHttpRequesteror something, but the current code is pretty tightly coupled to hyper at the moment.I've also made some simplifying assumptions for the moment, that may need to change before finishing (e.g. is
nosslstill an option that we care about? are all unsupported scheme errors are the same? etc)jdm commentedon Aug 2, 2015
Exciting! I am having trouble imagining how the split into two functions was managed, but perhaps I'm over-complicating matters in my head.
Abstracts the hyper connection to a servo HttpRequester trait
Abstract everything but the response from hyper
54 remaining items
Abstract everything but the response from hyper
Removes HttpRequest, adds HttpResponse wrapper
Adds tests for redirecting
Auto merge of #7139 - samfoo:testable-net-load, r=jdm
Refactors http_loader::load to be synchronous w/ an async wrapper
Injects the network connector as a dependency into http_loader::load
Abstracts out initial client connection and SSL errors (which I don't…
Adds simple POC unit test for load
Abstracts the hyper connection to a servo HttpRequester trait
Abstract everything but the response from hyper
Removes HttpRequest, adds HttpResponse wrapper
Adds tests for redirecting
Auto merge of #7139 - samfoo:testable-net-load, r=jdm
Auto merge of #7139 - samfoo:testable-net-load, r=jdm