Reputation: 3392
I need something quite different from question with similar subject.
I'm wondering if exist a .NET library that creates a real http request stream (obviously in parametric way). This is not for ASP.NET or other web framework, I want a raw stream of bytes (not mock objects of various http contexts).
I have intentionally omitted fake from the question title, because I need a real http request but I do not want a component that sent it over the network.
[note by ebohlman]: If I read you correctly, a clearer way of putting it is "... creates a simulated http request stream (at the raw-byte level) based on supplied parameters ..."
Basically I should be able to (it follows pseudo-C#):
[Fact]
void Parse_http_request_headers() {
HttpRequest req = HttpRequestBuilder.Create(HttpMethod.Get, "http://someserver/app/etc/etc");
HttpParser parser = new HttpParser(req.ToByteArray());
parser.Method.Should().Be("GET");
parser.Scheme.Should().Be("http");
// Remainder omitted
}
I just want to know if someone already created something like this.
Upvotes: 0
Views: 241
Reputation: 133975
One way to do this would be to create a program that uses TcpListener
to capture and save the request stream. Run it on your local computer.
Then, in a separate program, create a regular HttpWebRequest
and send it to the program that's listening. The listener saves the stream to a binary file, and you now have a request stream that you can examine.
Upvotes: 1