apache-commons-httpclient

HttpClient supporting multiple TLS protocols

╄→гoц情女王★ 提交于 2019-12-05 00:08:22
问题 We're writing an app that must communicate with a few servers using HTTPS. It needs to communicate with AWS (using the AWS libraries) and also with some of our internal services that use TLS 1.2. I started off by changing my HttpClient to use a TLS 1.2 SSLContext: public static SchemeRegistry buildSchemeRegistry() throws Exception { final SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(createKeyManager(), createTrustManager(), new SecureRandom()); final

Migrating from HttpClient 3.x to 4.x

别等时光非礼了梦想. 提交于 2019-12-04 23:52:40
We have some code written using commons-httpclient-3.1 that needs to be converted to 4.1. I'm only somewhat familiar with this and am reading the 4.1 httpclient tutorial now. I see a couple of posts here (e.g. Converting from HttpClient 3 to 4 but that's about a specific construct). Seems like there should be some docs/examples somewhere showing how to upgrade usage of 3.x to 4.x ? One specific example: replacing use of org.apache.commons.httpclient.HttpState I would replace the library jar(s) in your IDE and look for compiler errors to start with. You may wish to go back and check all usages

Issue with trying to Login to a https secure using apache commons httpclient class

依然范特西╮ 提交于 2019-12-04 14:27:55
问题 Iam trying to login to a https secured site using Apache commons httpclient. Iam not getting any way to pass the certificate along with my httprequest , since I cannot find any such classes in HttpClient Package. If anybody can guide me on where do I need to add the certificate handling? Any package to do it? Am open to ideas, any other way to do this in java. The platform must be only java however.. I have posted my code below. import java.net.MalformedURLException; import org.apache.commons

Upload Photo to Facebook with HttpClient

蹲街弑〆低调 提交于 2019-12-04 13:29:21
问题 I am attempting to use the following code to upload a photo to Facebook using the Graph API. I keep getting "Bad Request" but not sure why. I can upload the photo just fine using curl with the same parameters. I'm using Java with HttpClient. PostMethod filePost = new PostMethod('https://graph.facebook.com/me/photos'); filePost.setParameter('access_token', 'my-access-token') filePost.setParameter('message', 'test image') filePost.getParams().setBooleanParameter(HttpMethodParams.USE_EXPECT

Confused with different methods of creating cookie in HttpClient

做~自己de王妃 提交于 2019-12-04 12:21:22
问题 There are different methods to create cookies in HttpClient, I am confused which one is the best. I need to create,retrieve and modify cookies. For example , I can use the following code to see a list of cookies and modify them but how to create them ? Is this a proper method for retrieving them? I need them to be accessible in all classes. In addition methods that I have found usually require httpresponse, httprequest objects to send the cookie to browser, but how about if I do not want to

Why is this simple SOAP client not working (org.apache.http)?

折月煮酒 提交于 2019-12-04 09:56:05
I want to send an XML file as a request to a SOAP server. Here is the code I have: (modified from Sending HTTP Post request with SOAP action using org.apache.http ) import org.apache.http.client.*; import org.apache.http.client.methods.*; import org.apache.http.impl.client.*; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; import org.apache.http.HttpResponse; import java.net.URI; public static void req() { try { HttpClient httpclient = new DefaultHttpClient(); String body="xml here"; String bodyLength=new Integer(body.length()).toString(); URI uri=new URI(

Java HttpClient - Post with file through Proxy

大兔子大兔子 提交于 2019-12-04 05:09:24
问题 I try calling an external website from my webapplication with a proxy. Furthermore and need to execute a POST Request at this external website. I'm using: tomcat7, org.apache.httpcomponents 4.3.4, spring. Following, without proxy, works and I get a response status '200'; // uri = "https://punkte.eiv-fobi.de/upload/upload.do" private HttpStatus sendPost(URI uri, File file) throws ClientProtocolException, IOException { HttpClient httpClient = HttpClientBuilder.create().build(); HttpPost

HttpClient supporting multiple TLS protocols

给你一囗甜甜゛ 提交于 2019-12-03 15:45:58
We're writing an app that must communicate with a few servers using HTTPS. It needs to communicate with AWS (using the AWS libraries) and also with some of our internal services that use TLS 1.2. I started off by changing my HttpClient to use a TLS 1.2 SSLContext: public static SchemeRegistry buildSchemeRegistry() throws Exception { final SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); sslContext.init(createKeyManager(), createTrustManager(), new SecureRandom()); final SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("https", 443, new

Kerberos connection using HTTP Client

▼魔方 西西 提交于 2019-12-03 14:02:14
问题 I'm writing HTTP connection with Kerberos authentication. I have "HTTP/1.1 401 Unauthorized". Could you recommend me what I should check? I think there's somethink trick, but I don't see it. May be I should set header "WWW-Authenticate" with "Negotiate"? Thank a lot in advanced for any help and ideas. public class ClientKerberosAuthentication { public static void main(String[] args) throws Exception { System.setProperty("java.security.auth.login.config", "login.conf"); System.setProperty(

How do I pass the client certificate with HTTP client?

吃可爱长大的小学妹 提交于 2019-12-03 13:27:38
问题 I want to use mutual SSL authentication between service A and B. I'm currently implementing passing the client certificate from service A in Java. I'm using Apache DefaultHttpClient to execute my requests. I was able to retrieve the client certificate for my service A from an internal credential manager and I keep it as an array of bytes. DefaultHttpClient client = new DefaultHttpClient(); byte [] certificate = localCertManager.retrieveCert(); I have very little experience in this area and I