httpclient

With Apache HttpClient, why isn't my connection timeout working?

My implementation of httpclient occasionally throws an exception when calling doGetConnection(). However, I have the following timeout set _moHttpClient.setHttpConnectionFactoryTimeout(30000); it looks almost like my timeout is not being picked up. Is there anywhere else I need to set a timeout to ensure this behaviour does not re-occ...

how to register url handler for apache commons httpclient

I want to be able to access custom URLs with apache httpclient. Something like this: HttpClient client = new HttpClient(); HttpMethod method = new GetMethod("media:///squishy.jpg"); int statusCode = client.executeMethod(method); Can I somehow register a custom URL handler? Or should I just register one with Java, using URL.setURLStre...

HTTP posts and multiple threads in Java

I am writing an internal Java Applet to do file uploads via HTTP. I started using the built in ClientHttpRequest which worked great if I want to post one after another. When I try to have multiple threads post at the same time, something on the server side freaks out and the connection will hang for large files while still uploading th...

How do you programatically authenticate to a web server using NTLM Authentication with apache's commons httpclient?

I'm using this code, and I get the stack trace that is listed below. I've got this working with just https and with basic authentication, but not ntlm. HttpClient client = null; HttpMethod get = null; try { Protocol myhttps = new Protocol("https", ((ProtocolSocketFactory) new EasySSLProtocolSocketFactory()), 443); Protocol.registerP...

How do I add query parameters to a GetMethod (using Java commons-httpclient)?

Using Apache's commons-httpclient for Java, what's the best way to add query parameters to a GetMethod instance? If I'm using PostMethod, it's very straightforward: PostMethod method = new PostMethod(); method.addParameter("key", "value"); GetMethod doesn't have an "addParameter" method, though. I've discovered that this works: GetMe...

Code is HttpClient or servlet API to parse Cookie header

Is there any existing code in Apache HttpClient or in the servlet API to parse Cookie header and obtain from a string that contains "name1=value1; name2=value2; ..." a list of Cookie? Writing code to parse this doesn't seem too hard, but if there is already some existing code, I'd like to use it. ...

httpclient vs httpurlconnection

Wich are the main differences between the two? thanks ...

Can I use WCF Starter Kit HttpClient with confidence?

I would like to start using the WCF Rest Starter Kit's HttpClient to build clients for my Restful WCF services and I was wondering... If anyone is currently experience any problems with it Can I be confident that future versions of the component (just the HttpClient, not worried about the rest of the kit) will not contain significant ...

How to unit test a WCF Client built with WCF Rest Starter Kit

I created some POX services using the REST Starter kit. At first, it was a little complicated to create the unit tests for the service layer, but in the end, it was well designed and I succeed in mocking the context and set expectations. But, I'm starting in with the client side now, and I'm having some problems figuring out how to mock...

Unable to authenticate to SSL site in java: "pathLenConstraint violated - this cert must be the last cert in the certification path"

Hi, I'm trying to read from a secure (i.e. SSL) web page, in Java code. I'm trying to use both URLConnection (java.net) and Apache's HTTPClient. In both cases, when I make the request, I get this exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.securit...

How to send HTML as GET-Request parameter?

I would like to send a html string with a GET request like this with Apaches HttpClient: http://sample.com/?html=&lt;html&gt;&lt;head&gt;... This doesnt work at the moment, i think its an encoding problem. Do you have any ideas how to do that? method.setQueryString(new NameValuePair[] {new NameValuePair("report", "<html>....")}); cli...

Proxy doesn't work in HttpClient 4.0 beta2

Hi,i am useing HttpClient 4.0-beta2, to do rest call, it works fine in my lap-top, but in uni, we have to config our application to go through a proxy, otherwise, we cannot connect to internet Here is my orginal code: HttpClient httpclient = new DefaultHttpClient(); HttpPut put = new HttpPut("http://" + PutBlob.ACCOUNT + ".blob.core.w...

How can I force Java's HttpClient to accept invalid cookies?

I'm working on a script that logs into WordPress, however, HttpClient's cookie policy identifies the cookies set by WordPress to be invalid: May 17, 2009 12:07:43 PM org.apache.commons.httpclient.HttpMethodBase processCookieHeaders WARNING: Cookie rejected: "$Version=0; wordpress_dce2080bc042b2e639e4f5b3b704aa43=admin%7C1243786064%7C4c5...

How to upload a file using Java HttpClient library working with PHP - strange problem

I want to write Java application that will upload a file to the Apache server with PHP. The Java code uses Jakarta HttpClient library version 4.0 beta2: import java.io.File; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpVersion; import org.apache.http.client.HttpClient; import org.apa...

HTTPS authentication over WiFi using HttpClient 4

I have Android pet-project DroidIn which utilizes HttpClient 4 (built into Android) to do some form based authentication. I started noticing that people who are using WiFi are reporting connection problems. It also doesn't help that site I'm accessing has self-assigned certificate. Well - the question is (I'm quite vague on WiFi details)...

Looking for a framework that handles cancellation of HTTP Callables

I will be making multiple HTTP calls concurrently and want to allow the user to selectively cancel certain tasks if they take too long. A typical scenario: 1 task pulls twitter feed and another pulls facebook wall posts. The number of tasks is obviously variable, so the idea of a queue comes naturally. I've looked at ExecutorCompletionSe...

mediawiki API & encoding

I'm using the mediawiki Api to update some pages with an experimental robot. This robot uses the java apache http-client library to update the pages. (...) PostMethod postMethod = new PostMethod("http://mymediawikiinstallation/w/api.php"); postMethod.addParameter("action","edit"); postMethod.addParameter("title",page.replace(' ', '_'));...

handling a comma inside a cookie value using .net's (C#) System.Net.Cookie

I'm creating a client to visit a website and log in + do some tasks automatically, however they recently updated their cookies to (for whatever reason...) contain a comma inside their identification cookie. So for example, the Cookie will have a value similar to this: a,bcdefghijklmnop The problem is, according to msdn you can't use...

Apache HttpClient 4.0-beta2 httppost, how to add a referer?

I'm trying to add a referer to an http post in Apache HttpClient (httpclient-4.0-beta2). I found some sample code that does this. The code works, but I'm wondering if there is not a simpler, more straightforward way to add the referer than using the (ominously named) addRequestInterceptor, which appears to take an (yikes!) inner class a...

HttpClient request set Attribute question

Hi I play for a while (couple of weeks) with this HttpClient lib. I want somehow to set Attribute to the request. Not parameter but Attribute. In my servlet I want to use Integer inte = (Integer)request.getAttribute("obj"); I have no idea what i miss. i try this. NameValuePair[] pair = new NameValuePair[1]; pair[0] = new NameValuePair...