apache-httpclient-4.x

How to read body following an 101 response code?

落爺英雄遲暮 提交于 2019-12-11 17:56:11
问题 From the docs, immediately after sending the 101 (Switching Protocols) response, the server is expected to continue responding to the original request as if it had received its equivalent within the new protocol (i.e., the server still has an outstanding request to satisfy after the protocol has been changed, and is expected to do so without requiring the request to be repeated). If the Upgrade header field is received in a GET request and the server decides to switch protocols, it first

Apache HttpClient. How to properly produce multipart requests with Encoding

浪子不回头ぞ 提交于 2019-12-11 15:57:37
问题 Similar to the already existing question Apache HttpClient making multipart form post want to produce a http request, holding a file and a key=val pair. Currently the code looks like: HttpPost post = new HttpPost("http://localhost/mainform.cgi/auto_config.htm"); HttpEntity ent = MultipartEntityBuilder.create() .addTextBody("TYPE", "6",ContentType.TEXT_BINARY) .addBinaryBody("upname", new File("factory.cfg"),ContentType.APPLICATION_OCTET_STREAM,"factory.cfg") .build(); This is simply applied

apache httpclient 4.5.1 making only SSL connections to non-ssl sites, and failing

我的未来我决定 提交于 2019-12-11 13:45:40
问题 Currently I'm using httpclient 4.2.5 on jdk/tomcat v6, and it's running good.. In an attempt to upgrade, I moved to httpclient 4.5.1 on jdk/tomcat v8, and now getting different errors as below: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:992) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java

How to Authenticate Against Website Using Apache HttpClient 4.2.1 or >?

∥☆過路亽.° 提交于 2019-12-11 12:45:22
问题 I'm new to http programming and I'm attempting to authenticate against a website that doesn't use an API and I'm having some trouble. I found a few other questions that seemed to be similar to mine, but none had an answer that worked for me. I've tried several different approaches but haven't found one that works yet. Actually, I had it work for me once, but didn't check in that code (I know - what was I thinking?). I haven't been able to get back to that working version again. Here are a few

Issues with Apache HTTP Client and logging

末鹿安然 提交于 2019-12-11 12:06:14
问题 In my Tapestry application, I need to do a GET request to a certain URL at some point. I do it like this (using Apache's HttpClient 4.2.1) String scheme = getScheme(); String host = getHost(); int port = getPort(); String path = getPath(); String paramKey = getParamKey(); String paramValue = getParamValue(); URIBuilder builder = new URIBuilder(); builder .setScheme(scheme) .setHost(host) .setPort(port) .setPath(path) .setParameter(paramKey, paramValue); URI uri = builder.build(); HttpGet

Login page authentication with Httpclient and navigate to next page

狂风中的少年 提交于 2019-12-11 11:39:27
问题 I want to login to This website site which has username and password authentication and a login button. Is this code correct for login authentication. This code will help me navigate to next page? When I try to get the url of the navigated page it returns the login in page url. String UrlLink ="http://postimage.org/profile.php"; protected Object doInBackground(Object... params) { try { HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(UrlLink); List

apache http client NafHttpAuthStrategyDefault

纵然是瞬间 提交于 2019-12-11 07:57:20
问题 When I was using apache http client on android, I got a suspicious message in logcat. I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252) NafHttpAuthStrategyDefault() I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252) cached value : gbaSupportIsPossible=null I/APACHE HTTP (thCr=2252) - NafHttpAuthStrategyDefault(9949): (thUse=2252) The current context is NOT a context of GBA service. I/APACHE HTTP (thCr=2252) -

Automatically retry on 401 and send specific request with HttpClient 4.3

。_饼干妹妹 提交于 2019-12-11 06:59:37
问题 I use specific auth mechanism in the app. To login app sends login request to specific url /login/ and gets back session token that is stored in cookie. At any time token can be invalidated by server and other requests will result in 401. I want HttpClient to detect 401 error automatically, redo /login/ request once and retry original request automatically. I've tried setting HttpRequestRetryHandler in HttpClients.custom().setRetryHandler but it seems it does not handle 401 errors. What would

Dynamically configuring Apache Http client

那年仲夏 提交于 2019-12-11 06:55:42
问题 I am creating a module that uses http://hc.apache.org/httpcomponents-client-4.2.x/index.html to make HTTP requests to external services. This module is going to be used by application. The application configures different aspect of the module by XML based config file. and I want to specify the logging level to be used for http communication in that XML file. The module will read that config file, and configure apache HTTP client with that logging level. I could not find any way how

Async response streaming with Apache Async Http client

无人久伴 提交于 2019-12-11 05:45:22
问题 I am using apache async http client to stream objects from azure storage. I only need to return the HttpResponse object which has the stream associated. My clients will actually have to read from that stream to store the file locally. So Apache Async clients use a BasicAsyncResponseConsumer which actually buffers the entire file in local memory before calling the completed callback. I am trying to create my own implementation of AbstractAsyncResponseConsumer so that I can stream the response