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