httpclient

HttpClient response handler always returns closed stream

I'm new to Java development so please bear with me. Also, I hope I'm not the champion of tl;dr :). I'm using HttpClient to make requests over Http (duh!) and I'd gotten it to work for a simple servlet that receives an URL as a query string parameter. I realized that my code could use some refactoring, so I decided to make my own HttpRes...

Apache HttpClient Digest authentication

Hi, Basically what I need to do is to perform digest authentication. First thing I tried is the official example available here. But when I try to execute it(with some small changes, Post instead of the the Get method) I get a org.apache.http.auth.MalformedChallengeException: missing nonce in challange at org.apache.http.impl.auth.Dig...

Http request timed out only in GPRS/EDGE environment in Android phone

I am developing an Android app, it will connect to the internet to load some data back. I tested it with WIFI and it works well. But when I switched to use EDGE/GPRS, it always timed out, I have set a big timeout parameter for httpclient, but it did not help. It may caused by the server side that it did not return back a Content-Length...

Trying to run multiple HTTP requests in parallel, but being limited by Windows (registry)

I'm developing an application (winforms C# .NET 4.0) where I access a lookup functionality from a 3rd party through a simple HTTP request. I call an url with a parameter, and in return I get a small string with the result of the lookup. Simple enough. The challenge is however, that I have to do lots of these lookups (a couple of thousan...

Android httpclient - getting a file with preemptive authentication

Hello, I have problems getting the HTML code of a website by using this example code. http://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.0.x/httpclient/src/examples/org/apache/http/examples/client/ClientPreemptiveBasicAuthentication.java I have to use the above one, as I need preemptive authentication for my applicat...

Just need someone familiar with HTTPClient to check over a piece of code

here are two little helper methods I have made for downloading files. I have had to mix and match different tutorials of the web to get what I have here. Now is there anything that I have done blatantly wrong here? public static InputStream simplePostRequest(URL url, List<NameValuePair> postData) throws ClientProtocolException, IO...

Can you use POST to run a query in Solr (/select)

I have queries that I am running against out solr index that sometimes have very long query parameters, I get errors when i run these queries, which i assume are do to the limit of a GET query parameters. Here is the method I use to query (JSON), this is to show I am using the Http Extensions (the client i use is a thin wrapper for Http...

HttpClient - setting a "global" socket timeout, and a separate timeout per request

With HttpClient, I am setting the default socket/connection timeout with the following: HttpParams params = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(params, 30000); HttpConnectionParams.setConnectionTimeout(params, 30000); mClient = new DefaultHttpClient(connectionManager, params); I'm wondering if I can override the...

org.apache.http.impl.cookie.BasicClientCookie not serializable???

Dear All: I am quite confused... I am reading here and BasicClientCookie clearly implements Serializable per JavaDoc: http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/impl/cookie/BasicClientCookie.html However, my simple Groovy script: #!/usr/bin/env groovy @Grapes( @Grab(group='org.apache.httpcomponen...

How does one save cookies in HTTP Builder 0.5.0/HTTPClient

I am trying per instructions here: http://www.innovation.ch/java/HTTPClient/advanced_info.html However, if I am using HTTP Builder, the following lines System.setProperty("HTTPClient.cookies.save","true") System.setProperty("HTTPClient.cookies.jar","/home/misha/.httpclient_cookies") do not seem to create a file: ~/.httpclient_cookie...

ContentType issue with commons-upload and httpcomponent client

Hi, I am trying to develop a Http client which uploads a file with httpcomponents: HttpPost httppost = new HttpPost(myURL); httppost.setHeader("Content-type", "multipart/form-data; boundary=stackoverflow"); httppost.setHeader("Accept", "text/xml"); MultipartEntity reqEntity = new multipartEntity( HttpMultipartMode.BROWSE...

HTTP Post requests using HttpClient take 2 seconds, why?

Update: Found the answer myself, see below :-) Hi, I'am currently coding an android app that submits stuff in the background using HTTP Post and AsyncTask. I use the org.apache.http.client Package for this. I based my code on this example. Basically, my code looks like this: public void postData() { // Create a new HttpClient ...

Get web results from HttpClient for Android

For example: Say I searched something on the Walmart homepage. Like this. How would I retrieve the information from the first product listed. Information like product name, price, details, rating, model. And how would I search in the box. The only way it seems like to me is to replace http://www.walmart.com/search/search-ng.do?search_con...

HttpClient - supporting gzip

Is it easy to add gzip support to an existing codebase? This is a string based (JSON) API, where the client just makes a requests and parses the JSON data returned. It'd be great if I could add gzip support to this. I'm using HttpClient 4.x ...

Using Android to Post XML files

EDIT : I am trying to send an xml file as a post request in Android. The server accepts text/xml. I tried creating a MultipartEntity, which has a content type of multipart/form-data. HttpClient httpClient = new DefaultHttpClient(); /* New Post Request */ HttpPost postRequest = new HttpPost(url); byte[] data = IOUtils.t...

Java HttpClient: how to download all the files from a given folder

I am getting dynamic URLs, they point to Folders on servers like this: http://www.xyzdomain.com/images/ www.1234ooooo.com/documents/ I need to dowload all the files int the folder of a given url. I want this done apache httpclient package in java. Thanks in advance. ...

HttpClient - monitoring upload progress

Can I monitor the upload progress of a HttpPost request? ...

POST with HttpClient,how can I get the percent of upload

I want to upload a photo with POST use HttpClient,the photo has been change to String and it is a value in the POST,so the POST is so long,and I want to show the percent of this POST,such as show the percent with a processbar. How can I do that??Help me please. ...

How to login in web site using Java

Hi, I want to access some pages of web site https://myoffice.bt.com which requires user authentication using java. We have to sign in first to access pages. I have wriiten following code. package root; import java.io.IOException; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.UsernamePasswordCred...

Problems with httpclient and selfsigned certificates

Hi, I am sure this has been discussed in this group, but I couldn't find that thread, so bear with it, or if possible merge it with the original. I am using httpclient for my android app and I have a local site which has a few https pages. Since default httpclient doesnot allow self-signed certificates I am using "EasySSLFactory" and ...