|
|
@ -270,9 +270,9 @@ public class HTTPClient {
|
|
|
|
* @throws IOException
|
|
|
|
* @throws IOException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public byte[] GETbytes(final String uri, long maxBytes) throws IOException {
|
|
|
|
public byte[] GETbytes(final String uri, long maxBytes) throws IOException {
|
|
|
|
MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final HttpGet httpGet = new HttpGet(url.toNormalform(true, false, true, false));
|
|
|
|
final HttpGet httpGet = new HttpGet(url.toNormalform(true, false, true, false));
|
|
|
|
httpGet.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
// httpGet.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
return getContentBytes(httpGet, maxBytes);
|
|
|
|
return getContentBytes(httpGet, maxBytes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -286,9 +286,9 @@ public class HTTPClient {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void GET(final String uri) throws IOException {
|
|
|
|
public void GET(final String uri) throws IOException {
|
|
|
|
if (currentRequest != null) throw new IOException("Client is in use!");
|
|
|
|
if (currentRequest != null) throw new IOException("Client is in use!");
|
|
|
|
MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final HttpGet httpGet = new HttpGet(url.toNormalform(true, false, true, false));
|
|
|
|
final HttpGet httpGet = new HttpGet(url.toNormalform(true, false, true, false));
|
|
|
|
httpGet.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
// httpGet.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
currentRequest = httpGet;
|
|
|
|
currentRequest = httpGet;
|
|
|
|
execute(httpGet);
|
|
|
|
execute(httpGet);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -301,9 +301,9 @@ public class HTTPClient {
|
|
|
|
* @throws IOException
|
|
|
|
* @throws IOException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public HttpResponse HEADResponse(final String uri) throws IOException {
|
|
|
|
public HttpResponse HEADResponse(final String uri) throws IOException {
|
|
|
|
MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final HttpHead httpHead = new HttpHead(url.toNormalform(true, false, true, false));
|
|
|
|
final HttpHead httpHead = new HttpHead(url.toNormalform(true, false, true, false));
|
|
|
|
httpHead.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
// httpHead.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
execute(httpHead);
|
|
|
|
execute(httpHead);
|
|
|
|
finish();
|
|
|
|
finish();
|
|
|
|
ConnectionInfo.removeConnection(httpHead.hashCode());
|
|
|
|
ConnectionInfo.removeConnection(httpHead.hashCode());
|
|
|
@ -322,9 +322,9 @@ public class HTTPClient {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void POST(final String uri, final InputStream instream, long length) throws IOException {
|
|
|
|
public void POST(final String uri, final InputStream instream, long length) throws IOException {
|
|
|
|
if (currentRequest != null) throw new IOException("Client is in use!");
|
|
|
|
if (currentRequest != null) throw new IOException("Client is in use!");
|
|
|
|
MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));
|
|
|
|
final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));
|
|
|
|
httpPost.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
// httpPost.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
final InputStreamEntity inputStreamEntity = new InputStreamEntity(instream, length);
|
|
|
|
final InputStreamEntity inputStreamEntity = new InputStreamEntity(instream, length);
|
|
|
|
// statistics
|
|
|
|
// statistics
|
|
|
|
upbytes = length;
|
|
|
|
upbytes = length;
|
|
|
@ -342,9 +342,9 @@ public class HTTPClient {
|
|
|
|
* @throws IOException
|
|
|
|
* @throws IOException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public byte[] POSTbytes(final String uri, final Map<String, ContentBody> parts, final boolean usegzip) throws IOException {
|
|
|
|
public byte[] POSTbytes(final String uri, final Map<String, ContentBody> parts, final boolean usegzip) throws IOException {
|
|
|
|
MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final MultiProtocolURI url = new MultiProtocolURI(uri);
|
|
|
|
final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));
|
|
|
|
final HttpPost httpPost = new HttpPost(url.toNormalform(true, false, true, false));
|
|
|
|
httpPost.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
// httpPost.setHeader("Host", url.getHost()); // overwrite resolved IP
|
|
|
|
|
|
|
|
|
|
|
|
final MultipartEntity multipartEntity = new MultipartEntity();
|
|
|
|
final MultipartEntity multipartEntity = new MultipartEntity();
|
|
|
|
for (final Entry<String,ContentBody> part : parts.entrySet())
|
|
|
|
for (final Entry<String,ContentBody> part : parts.entrySet())
|
|
|
|