{"action":"created","issue":{"url":"https://api.github.com/repos/servo/servo/issues/6727","labels_url":"https://api.github.com/repos/servo/servo/issues/6727/labels{/name}","comments_url":"https://api.github.com/repos/servo/servo/issues/6727/comments","events_url":"https://api.github.com/repos/servo/servo/issues/6727/events","html_url":"https://github.com/servo/servo/issues/6727","id":97042482,"number":6727,"title":"The networking code is hard to test","user":{"login":"jdm","id":27658,"avatar_url":"https://avatars.githubusercontent.com/u/27658?v=3","gravatar_id":"","url":"https://api.github.com/users/jdm","html_url":"https://github.com/jdm","followers_url":"https://api.github.com/users/jdm/followers","following_url":"https://api.github.com/users/jdm/following{/other_user}","gists_url":"https://api.github.com/users/jdm/gists{/gist_id}","starred_url":"https://api.github.com/users/jdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdm/subscriptions","organizations_url":"https://api.github.com/users/jdm/orgs","repos_url":"https://api.github.com/users/jdm/repos","events_url":"https://api.github.com/users/jdm/events{/privacy}","received_events_url":"https://api.github.com/users/jdm/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/servo/servo/labels/A-network","name":"A-network","color":"d7e102"},{"url":"https://api.github.com/repos/servo/servo/labels/A-testing","name":"A-testing","color":"d7e102"},{"url":"https://api.github.com/repos/servo/servo/labels/E-less%20easy","name":"E-less easy","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-24T12:32:49Z","updated_at":"2015-07-30T04:59:34Z","closed_at":null,"body":"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!\r\n\r\nI propose the following:\r\n* we create a new `Response` struct that contains all of the data used by Servo's networking stack from [hyper's Response](http://doc.servo.org/hyper/client/response/struct.Response.html)\r\n* 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\r\n* 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\r\n* we figure out what else makes `http_loader::load` difficult to test"},"comment":{"url":"https://api.github.com/repos/servo/servo/issues/comments/126183755","html_url":"https://github.com/servo/servo/issues/6727#issuecomment-126183755","issue_url":"https://api.github.com/repos/servo/servo/issues/6727","id":126183755,"user":{"login":"samfoo","id":26163,"avatar_url":"https://avatars.githubusercontent.com/u/26163?v=3","gravatar_id":"","url":"https://api.github.com/users/samfoo","html_url":"https://github.com/samfoo","followers_url":"https://api.github.com/users/samfoo/followers","following_url":"https://api.github.com/users/samfoo/following{/other_user}","gists_url":"https://api.github.com/users/samfoo/gists{/gist_id}","starred_url":"https://api.github.com/users/samfoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samfoo/subscriptions","organizations_url":"https://api.github.com/users/samfoo/orgs","repos_url":"https://api.github.com/users/samfoo/repos","events_url":"https://api.github.com/users/samfoo/events{/privacy}","received_events_url":"https://api.github.com/users/samfoo/received_events","type":"User","site_admin":false},"created_at":"2015-07-30T04:59:34Z","updated_at":"2015-07-30T04:59:34Z","body":"Hey guys, I'll pick this up over the weekend."}}