apache-httpcomponents

Getting redirected URL in Apache HttpComponents

吃可爱长大的小学妹 提交于 2019-12-24 23:29:41
问题 I'm using Apache HttpComponents to GET some web pages for some crawled URLs. Many of those URLs actually redirect to different URLs (e.g. because they have been processed with a URL shortener). Additionally to downloading the content, I would like to resolve the final URLs (i.e. the URL which provided the downloaded content), or even better, all URLs in the redirect chain. I have been looking through the API docs, but got no clue, where I could hook. Any hints would be greatly appreciated.

Apache HTTP BasicScheme.authenticate deprecated?

耗尽温柔 提交于 2019-12-22 04:13:51
问题 In Apache HTTP Component 4 class org.apache.http.impl.auth.BasicScheme I noticed that the method: public static Header authenticate( final Credentials credentials, final String charset, final boolean proxy) Is deprecated with the following information: /** * Returns a basic <tt>Authorization</tt> header value for the given * {@link Credentials} and charset. * * @param credentials The credentials to encode. * @param charset The charset to use for encoding the credentials * * @return a basic

Problems including Apache HttpComponents in Android Gradle project

情到浓时终转凉″ 提交于 2019-12-21 04:21:07
问题 I try to include httpmime in my application using the build.gradle file, and everything compiles fine. Instead, when the application tries to actually use the MultipartEntityBuilder class, there are a bunch of WARN level messages on the log saying that there are problems. Here's the excerpt from my build.gradle for the dependency: compile('org.apache.httpcomponents:httpmime:4.+') { exclude module: "httpclient" } Here are the errors: 10-09 13:39:37.367 2409-2426/com.company.app W/dalvikvm﹕ VFY

“ConnectionPoolTimeoutException” when iterating objects in S3

旧巷老猫 提交于 2019-12-20 12:05:42
问题 I've been working for some time with aws java API with not so many problems. Currently I'm using the library 1.5.2 version. When I'm iterating the objects inside a folder with the following code: AmazonS3 s3 = new AmazonS3Client(new PropertiesCredentials(MyClass.class.getResourceAsStream("AwsCredentials.properties"))); String s3Key = "folder1/folder2"; String bucketName = Constantes.S3_BUCKET; String key = s3Key +"/input_chopped/"; ObjectListing current = s3.listObjects(new ListObjectsRequest

How to use apache http on Android P

雨燕双飞 提交于 2019-12-19 01:39:28
问题 When I run my app in Android P devices, I get some error like this: java.lang.RuntimeException: Unable to instantiate application com.le.android.client.LeApplication: java.lang.ClassNotFoundException: Didn't find class "com.le.android.client.LeApplication" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.le.android.client-uvQkO641-__8Z_p2oT0t7g==/base.apk"],nativeLibraryDirectories=[/data/app/com.le.android.client-uvQkO641-__8Z

Java- apache http client- usage examples showing use of cookies and extracting response from HTTPResponse object

浪子不回头ぞ 提交于 2019-12-18 16:56:51
问题 I am working with apache http client (v4) in a java web app, and I am stuck in the following cases, for which I require simple usage examples-- (1) How to use Cookies with Apache HTTP client, different options available for usage of cookies (2) Extracting charset, mimetype, response headers (as KeyValuePair) and budy (as byte[]) when the response is available in HTTPResponse object. 回答1: 1)AS for cookies,see that exapmle: httpcomponents-client-4.1.3\examples\org\apache\http\examples\client

Apache Http Client prints “[read] I/O error: Read timed out”"

匆匆过客 提交于 2019-12-18 15:29:10
问题 I am using apache http client v4.5 and using it as a REST client. In some cases I recognize an error "[read] I/O error: Read timed out" which comes from the httpclient framework when it reads the received content and shows it as a last message. It seems not to have an impact, however I wonder if somebody has an idea where it is coming from and how it can be solved. According the following thread (link) it seems to be an issue with the "mutlithreaded" configuration. However I use only the

Error while trying to use an API. java.lang.NoSuchFieldError: INSTANCE

◇◆丶佛笑我妖孽 提交于 2019-12-17 20:06:39
问题 I am trying to connect to the smartsheet api using a java program. Initially I had problems with the site certificate which was resolved by adding it to the java keystore. Now when I am trying to run my code, I get the following error. Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:144) at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:955) at org.apache

Apache HttpClient resolving domain to IP address and not matching certificate

不问归期 提交于 2019-12-14 03:44:02
问题 When using the Apache HttpComponents HttpClient library (4.0.2) I'm having a problem where the certificate doesn't get validated properly. The certificate is valid for the domain name (let's call it example.com) however it's getting validated against the IP address instead: hostname in certificate didn't match: <123.123.123.123> != <*.example.com> My code for making the connection is: HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, 5000);

How to send serialized object to a servlet using Apache HttpClient

天涯浪子 提交于 2019-12-14 02:25:37
问题 I have a Main() class where I serialize an object of a class called Names . I am using Apache HttpClient 's HttpPost() to call a servlet . public static void main(String[] args) { Names names = new Names(); names.setName("ABC"); names.setPlace("Bangalore"); ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("Name.txt")); out.writeObject(names); out.close(); HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost("http://localhost:6080/HttpClientGson