httpclient

Convert HttpURLConnection to HttpClient using multipart to send JSON + data files

I do not have as good of an understanding of HTTP as I would like to. Any insight will be greatly appreciated! I needed to upload a JSON that contained information about an object. This object could have image, audio, and video files associated with it. These data files had to be uploaded, after the JSON, as part of a multipart reque...

Load image from url in Android, only if small

I'm using BitmapFactory.decodeStream to load an image from a url in Android. I want to only download images below a certain size, and I'm currently using getContentLength to check this. However, I'm told that getContentLength doesn't always provide the size of the file, and in those cases I would like to stop the download as soon as I ...

Content-Length header already present

I am using the Apache HttpClient (4.1) included in Android to execute a HttpPut. I have verified that I only have 1 content-length header. However, every time I send the request, I get a protocol exception about the Content-Length header already specified. HttpClient client = new DefaultHttpClient(); putMethod = new HttpPut(url + enco...

Add parameters to Apache HttpPost

Hello, I'm trying to send a file to a Servlet. Along with this file, I also have to send some parameters (i.e. name/id, date and a few others). I'm using HttpClient on client-side and ServerFileUpload on server-side. This is the client-side code: ... String url = "http://localhost:8080/RicezioneServlet/RicezioneServlet"; HttpClient htt...

HttpClient Default Headers

Is there a way to configure default request headers for HttpClient (the newer version)? I've done a lot of searching but I can't find anything on the new version. ...

Mutual Authentication with x509 Certificates using HttpClient 4.0.1

Does anyone have any friendly tips on how to perform client authentication via an x509 certificate using HTTPClient 4.0.1? Thank you for your time. ...

Apache HttpClient in Android extremely slow downloading attachment

I am trying to download a zip file using HttpCLient 4 and it is going at around .5 (kilobytes/kilobits)? per minute. The file is less than a MB large, and the download will probably take an hour! Am I doing something wrong? How else should I do this? Here is my current implementation: @Override protected Uri doInBackground(S...

Apache DefaultHttpClient invocation results in "java.lang.RuntimeException: Stub!"

I'm dipping my toes into Android development. I have a project that will interface with a RESTful resource and I'm trying to figure out how to do a basic GET with params over HTTP. From everything I've read, the consensus seems to be favoring HTTPClient over HttpURLConnection. I've written a wrapper class with a method that takes care o...

How to send a cookie along with HttpGet in Java

I am trying to send a cookie along with my HttpGet request, but everytime I try I havent been able to successfully send it. I also tried to modify the headers directly, here is my code: DefaultHttpClient httpclient = new DefaultHttpClient(); CookieStore store = new BasicCookieStore(); store.addCookie(Authentication....

HTTP get method returns http host connect exception

Hello all, I am trying to get the response from a URI using httpclient and httpget. when i am trying to execute the httpclient.execute method it is giving me the http host connect exception. However when i am passing the same URI to the XML parsing code as inputstream the code works fine. Does someone has any idea on the problem.. Help...

Does HTTPClient handle SAN SSL certs?

I have a Verisign issued "Subject Alternative Name" (SAN) SSL cert. This cert allows for multiple domain names. Does anyone know if httpclient supports this? We tried but it did not like the cert. Thanks, Tom ...

Android emulator to communicate with pc emulator running on

I have an application that I will run on two separate emulators. This application uses httpclient to communicate to the server application, that I will run on the same computer as the emulators are running. "localhost" for the android emulator wont work as local would be the emulator itself. The computer will not be connected to a lap...

What port does httpclient use?

80, 8080, ....? ...

HttpClient redirecting to URL with spaces throwing exception

I am accessing a URL that's redirecting me to a URL with spaces in it. (Using HttpClient 4.x) How do I prevent this from throwing an error (replacing the spaces with %20 not +) 08-06 02:45:56.486: WARN/System.err(655): org.apache.http.client.ClientProtocolException 08-06 02:45:56.493: WARN/System.err(655): at org.apache.http.impl.cl...

Android: log into website and preserve session/cookie using DefaultHttpClient

Hi, I've been through different tutorials and this website, but couldn't find a proper solution. On the other hand, I've seen apps logging into websites and requesting further information, so I'm sure there's a way to get this working, but maybe my approach is all wrong. Here's what I'm trying to do: I want to log into a website that n...

setup httpclient proxy to access REST url on EC2

I have an EC2 imaging running and hosting a REST service accessible from Url. The following is what I did 1) ssh -i D port user@ec2-host 2) setup proxy in the firefox web browser and type in the url http://ec2-host:port/demo/workflow/lists/demo_workflow It works fine. Now I need to send the GET method using Java program, below is my c...

What I have to do to solve "java.lang.IllegalArgumentException"?

Hello Friends, I am trying to process the following URL via the HttpGet method: https://graph.facebook.com/search?q=Cafe++Bakery&type=event&access_token=&type=event&access_token=239090718395|lqqOnRWlcJOb3QGp3G4HW2aqhlc. And I get the following exception: java.lang.IllegalArgumentException: Invalid uri 'https://gr...

Java HttpClient media not supported error for POST method

I am trying to use httpclient and I am getting media not supported error. I want to set the headers and then get the response back which should return me headers which are tokens for authentication Error: Method failed: HTTP/1.1 415 Unsupported Media Type The procedure is as follows: public void getDocument(String url) { PostMethod...

Servlet Session HTTPClient

I got a Servlet A which has a HTTPClient configured in it - declared a GetMethod which calls Servlet B (basically passing the url to the constructor of Servlet B". In Servlet B I am setting some session vars and when the Servlet A gets back the control after the "execute" method but the session vars set in Servlet B are returning as nu...

Problem displaying request headers with apache httpclient 4

I've been trying to retrieve the headers sent by a HttpMethod, using HttpClient 4, but without any success... here is my code : HttpClient httpClient = new DefaultHttpClient(); HttpParams httpParams = httpClient.getParams(); HttpGet httpGet = new HttpGet("http://www.google.fr"); HttpResponse response = httpClient.execute(httpGet); ...