mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
added parameter for gzip encoding to HttpRequest
This commit is contained in:
@@ -169,6 +169,19 @@ public class HttpRequest
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
public boolean isDecodeGZip()
|
||||
{
|
||||
return decodeGZip;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -188,6 +201,22 @@ public class HttpRequest
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param decodeGZip
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @since 1.14
|
||||
*/
|
||||
public HttpRequest setDecodeGZip(boolean decodeGZip)
|
||||
{
|
||||
this.decodeGZip = decodeGZip;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -247,6 +276,9 @@ public class HttpRequest
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private boolean decodeGZip = false;
|
||||
|
||||
/** Field description */
|
||||
private Map<String, List<String>> headers;
|
||||
|
||||
|
||||
@@ -251,7 +251,8 @@ public class URLHttpClient implements HttpClient
|
||||
{
|
||||
String url = createGetUrl(request.getUrl(), request.getParameters());
|
||||
|
||||
return new URLHttpResponse(openConnection(request, url));
|
||||
return new URLHttpResponse(openConnection(request, url),
|
||||
request.isDecodeGZip());
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
@@ -70,8 +70,21 @@ public class URLHttpResponse implements HttpResponse
|
||||
* @param connection
|
||||
*/
|
||||
public URLHttpResponse(URLConnection connection)
|
||||
{
|
||||
this(connection, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param connection
|
||||
* @param decodeGZip
|
||||
*/
|
||||
public URLHttpResponse(URLConnection connection, boolean decodeGZip)
|
||||
{
|
||||
this.connection = connection;
|
||||
this.decodeGZip = decodeGZip;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@@ -114,7 +127,7 @@ public class URLHttpResponse implements HttpResponse
|
||||
String enc = connection.getContentEncoding();
|
||||
InputStream input = null;
|
||||
|
||||
if (Util.isNotEmpty(enc) && enc.contains(ENCODING_GZIP))
|
||||
if (decodeGZip || (Util.isNotEmpty(enc) && enc.contains(ENCODING_GZIP)))
|
||||
{
|
||||
input = new GZIPInputStream(connection.getInputStream());
|
||||
}
|
||||
@@ -215,8 +228,11 @@ public class URLHttpResponse implements HttpResponse
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private boolean clientClose = false;
|
||||
private URLConnection connection;
|
||||
|
||||
/** Field description */
|
||||
private URLConnection connection;
|
||||
private boolean decodeGZip = false;
|
||||
|
||||
/** Field description */
|
||||
private boolean clientClose = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user