Created
June 4, 2012 06:45
-
-
Save domenic/2866738 to your computer and use it in GitHub Desktop.
HTTP mocking library idea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mockHttp = require("mock-http"); | |
var a = mockHttp.server.request().errorsWith(new Error()); | |
var b = mockHttp.server.request().respondsWith(mockHttp.response.errorsWith(new Error())); | |
var c = mockHttp.server.request().respondsWith("string"); | |
var d = mockHttp.server.request().respondsWith("string", headersHash); | |
var A = mockHttp.server.response("text of response", optionalHeadersHash); | |
var B = mockHttp.server.response().data("text").error(new Error()); | |
var C = mockHttp.server.response().data("text").data("more text"); | |
var D = mockHttp.server.response().headers(headersHash).data("text").error(new Error()); | |
// Content-Length/Content-Type should always be computed/inferred if possible, but of course overwritable if explicitly specified. | |
// Also will need client.request, client.response, with appropriate writability. | |
// Needs to be able to detect and warn about the following common failure modes: | |
// * .writeHead called after stream was already written to | |
// * missing data listeners |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment