0

I'm using a Http Sniffer to capture http message on my Android phone. Each request the app save two file:

1.File named "rawdata.bin": The raw http response message, contains http response header and http response body. enter image description here 2.File named "body.json" An JSON file contains the http response body data. This data is humand friendly text. enter image description here

My problems is: I want to get the JSON data from the file named "rawdata.bin" directly in C#. But it's look like encoded, how do I convert it ?

enter image description here

This is what I tried

I opened the file named "rawdata.bin" with Notepad++ and remove header part (include the blank line between header and body) then save to file named body.hcy

This is my code, but it doesn't work as expected.

enter image description here

This is my raw http response packet file: file[.]io/YdO53cAU26Up

Giang Nguyễn
  • 105
  • 1
  • 9
  • I assume you are writing the loaded data directly to the response body as string and you are converting the loaded data to UTF8 before? – monty Jul 08 '21 at 05:25
  • The clue is; "Content-Encoding: gzip". You need to deflate it. But you haven't posted any code that describes what you are actually doing.... It's a pity that the dotnet runtime parser is not reusable https://stackoverflow.com/a/59314866/4139809 – Jeremy Lakeman Jul 08 '21 at 06:20
  • @JeremyLakeman I just updated my code. Please help me bro. – Giang Nguyễn Jul 08 '21 at 06:36
  • I think the usual `HttpClient` Http/1.1 response parsing happens [here](https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs#L589). which you might be able to copy. – Jeremy Lakeman Jul 08 '21 at 06:46
  • This is my packet file, please help me to decode the body: file[.]io/YdO53cAU26Up – Giang Nguyễn Jul 08 '21 at 08:32
  • Do you have to do this in C#? Does your http sniffer have any option to decode the payload? Are you trying to do this once, or do you need build this into some other application? – Jeremy Lakeman Jul 09 '21 at 02:58

0 Answers0