Decompress gzipped http request - android

I'm trying to decompress an HTTP POST request originating from my Android handset. I've set up a proxy using Fiddler to capture the requests but am having a hard time trying to decompress the captured data. I'm using an windows laptop to run Fiddler to capture the requests over WiFi.

Fiddler will automatically decode gzip all responses if you toggle the toolbar button "Decode". Otherwise you can do it manually for a response by clicking the yellow bar above the response view. It says "Response body is encoded, click to decode".

Related

EOFException after server responds

I have a quite simple problem but I've still couldn't find a solution yet.
What I want to accomplish:
I'm trying to establish a reliable connection between a smartphone running Android and the ESP8266 wifi module. I would like to send short HTTP string messages, where the phone plays the role of a client and the ESP8266 of a server. For managing HTTP requests I'm using the Volley library.
What already works:
I am able to do a successful HTTP GET request to the ESP8266 from a browser running on the Android phone. I also managed to use Volley to make a GET request to a server running on the web.
What doesn't work:
On the other hand, I cannot successfully send a GET request to ESP8266 using Volley. To be more precise, I get an EOFException when the server (ESP8266) tries to close the connection after it has responded. When using a browser the body of the response gets displayed after the connection is closed but in case of Volley the connection closing fails and shuts down the server.
I have no idea how to solve this problem/bug. What frustrates me is that the same commands for sending a HTTP response on the ESP work well when using a web browser but fail when using Volley. So I guess the problem is something about Volley.
Any ideas why Volley throws such exception? Any help would be deeply appreciated.

Android upload image via HTTP PUT

I'm trying to upload a jpeg image to my web server via an HTTP PUT method.
With Fiddler, I'm able to compose an HTTP PUT request, upload the image and execute the request successfully.
However, on Android, I can't get it to work. I've read many solutions about using MultipartEntity. When I try that, the image received on the server is corrupted. I compared the content of the original image with the one received by the server and I see that some HTTP headers are added at the beginning of the file and that the multipart boundary is added at the end, therefore corrupting it.
I've set up Fiddler on the web server as a reverse proxy to capture the incoming HTTP traffic:
here's the result
On the top, the HTTP PUT request sent with Fiddler that works.
At the bottom, the one sent by my Android application that sends a corrupted image.
How can I send an HTTP PUT request on Android that will produce a similar request than the one sent with Fiddler?

get push stream in response send by server push with OkHttp

I am trying to test the push response from a server which support HTTP2 Server with an android app (Os=Android KitKat) . The server push another ressources(pictures) after a http request for index.html.
I don't know how to access to push stream (picture). I have done capture on server and it send the push stream. But the client (Okhttp 2.1.0) always send a frame RST_STREAM and just return the index page content .
I just start use okhttp and would like to know how to acces push stream from Okhttpclient response ? I have read that that it exist API for handle push stream from HTTP2. is it available in Okhttp 2.1.0 or Okhttp 2.2.0?
Thanks.
OkHttp doesn't implement pushed streams yet. When we do, it'll likely be to push into the cache only.

android post gzip

Trying to implement gzip on an Android project to reduce client data charges. All devices connect to a WCF webservice and IIS is now sending compressed data back to the devices as expected. Now I need to work out how to post back gzipped xml data modified on the android device.
The device code is as follows
httpsURLConnection.setDoInput(true);
httpsURLConnection.setDoOutput(true);
httpsURLConnection.setConnectTimeout(TIMEOUT);
httpsURLConnection.setReadTimeout(TIMEOUT);
httpsURLConnection.setRequestMethod("POST");
httpsURLConnection.setRequestProperty("Content-Type", "application/xml");
httpsURLConnection.setRequestProperty("Content-Encoding", "gzip);
httpsURLConnection.connect();
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(new BufferedOutputStream((httpsURLConnection.getOutputStream())));
gzipOutputStream.write(_xmlText.getBytes());
gzipOutputStream.flush();
gzipOutputStream.finish();
gzipOutputStream.close();
Running Wireshark on webserver shows the gzip packets and decompresses them to show the correct data from the device.
The problem is that the WCF web service does not seem to recognise the data - the error is XmlException - The data at the root level is invalid. Line 1, position 1.
Which makes me think that the data is still compressed and WCF cannot handle gzip - which I seem to remember reading about previously. Do I then need to create a message decoder in .net to handle the gzip compression? Was this hopefully addressed in .net 4.5?
Any help with these questions appreciated.

Disable gzip content-encoding in android simulator

I was trying to read the HTTP messages between the browser in the Android simulator and other third party web-servers using tcpdump. However, since the browser can accept gzip content-encoding, I can't see the HTML content as plain-text in the tcpdump output. Is there a way to change the configs of the browser so that it doesn't send that Accept-Encoding: gzip header line?
This post implies if you remove the
Accept-Encoding
header, you'll get raw data back... you should be able to write a custom WebView that never sends that header. Hope that works!
http://forgetmenotes.blogspot.com/2009/05/how-to-disable-gzip-compression-in.html

Categories

Resources