Android upload image via HTTP PUT - android

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?

Related

Decompress gzipped http request

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".

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.

Sending body via POST on redirect

I have an established code base which successfully makes GET and POST requests to a server to download/upload data. We're looking to change the domain name and have set up a 301 HTTP redirect to go from the original domain to the new domain. When doing a GET request, it seems to automatically handle the redirect in the background and successfully retrieves the response. When I am sending a body via POST, however, it throws a java.net.ProtocolException: content-length promised xx bytes, but received 0.
Is there any way to ensure that the body is sent in the redirect request as well? Thanks for any help in advance!

sending request from client to Android Web Server using Paw Server (Vice versa)

I configured paw server and basically can send request however dont find how to handle incoming requests from client on the serverside. Can anyone give any information how to do that?
EDIT: I can send request with GET action saying something at url like ihttp://192.168.12.103:7575/?testparametre=mustafa%20guven
and I can get it in index.html like below
gelenParametre = <bsh>$$.print(parameters.get("testparametre"));</bsh>
But what I want to do is getting the request in Activity Lifecycle. How do I achieve this?
You have to specify a xhtml page:
_http://192.168.12.103:7575/test.xhtml?testparametre=mustafa%20guven
The code inside the test.xhtml file should look like this:
<bsh>
gelenParametre = parameters.get("testparametre");
print(gelenParametre);
</bsh>

Getting Size of Http request and response

I am study about doPost and get method to send data from android app to tomcat server.
I am trying to check the size of http request and response because I am sure that request and response was sending data and catching data from tomcat server.
I used this example ,
http://www.avajava.com/tutorials/lessons/how-do-i-determine-the-content-length-of-a-request.html
to check the contents length.
After I get contents length, i get two questions
First, contents-length represents whole size of http request ?
if it is not, then how can i check the size of http request (by bytes)?
second , I am still having a trouble to getting size of response ?
I tried
How to Get the HTTP Response Size in Java (in Bytes)
Determine size of HTTP Response?
but i was getting error to get size of http response
is there any way to get size of http response ?
thanks
No, it is not the size of the whole request. It is the length of the message body, excluding status line and headers.
Not all servers provide the content length. If you use chunked transfer encoding, the content length cannot be determined without downloading the whole response. If the server sends the "Content-Length" header, you can get the size of the message body. You need to hook the socket stream to get the actual (full) response size.

Categories

Resources