-1

I'd like to be able to deserialize a file containing a web request into some .NET structure that I could then use to make the request. The following is an example of the file;

POST http://127.0.0.1/Foo HTTP/1.1
Accept: application/json
User-Agent: MyAgent/1.0
Content-Type: text/xml
Host: 127.0.0.1
Content-Length: 14
Accept-Encoding: gzip, deflate

This is payload

Ideally, I'd like to be able to construct something like a WebRequest class which would give me access to headers, verbs etc. I could probably write something but I'd rather not have to deal with lots of edge cases.

I'd like to use it to drive some testing ...Are there any BCL types/methods that allow this?

Jason Hyland
  • 744
  • 1
  • 8
  • 21
  • You haven't asked a question – Jonesopolis Mar 14 '14 at 13:33
  • Your question doesn't really make sense. Deserialize a file containing a web request ?? What does that mean? – Steve Mar 14 '14 at 13:38
  • Really? Let me try again - If I post to a web page, it sends over the wire the text above. I capture that text in, say, fiddler, and save it to a text file. What I'd now like to do is use that file to reconstruct a web request object that I could use to replay the post to the web page. – Jason Hyland Mar 14 '14 at 13:43
  • I'm not sure if I understand correctly, but you can use JSON.NET to serialize a .NET Class with all the necessary attributes for replaying the request into a JSON string structure which can then be deserialized later. – Steve Mar 14 '14 at 13:46
  • Why manually copy-pasting? If you are doing all that in your code, you can try what is mentioned here http://stackoverflow.com/a/2934308/125740 – Yahya Mar 14 '14 at 13:56
  • @Yahya That's not really relevant or helpful - I don't have a problem copying the request as it's caught in fiddler. *I need to get that request into something like a HttpWebRequest object* – Jason Hyland Mar 14 '14 at 14:02
  • @JasonHyland how are those requests generated? From code or you are intercepting? – Yahya Mar 14 '14 at 14:06
  • @Yahya Caught from fiddler. – Jason Hyland Mar 14 '14 at 14:16

1 Answers1

0

I ended up writing a simple parser for this.

Jason Hyland
  • 744
  • 1
  • 8
  • 21