1313import org .apache .http .HttpEntity ;
1414import org .apache .http .HttpHeaders ;
1515import org .apache .http .HttpResponse ;
16- import org .apache .http .client .methods .HttpGet ;
16+ import org .apache .http .client .methods .HttpHead ;
1717import org .apache .http .impl .client .CloseableHttpClient ;
1818import org .apache .http .impl .client .HttpClientBuilder ;
1919import org .apache .http .util .EntityUtils ;
@@ -82,12 +82,12 @@ final String expandSafe(final String urlArg) throws IOException {
8282 }
8383
8484 final Pair <Integer , String > expandSingleLevelSafe (final String url ) throws IOException {
85- HttpGet request = null ;
85+ HttpHead request = null ;
8686 HttpEntity httpEntity = null ;
8787 InputStream entityContentStream = null ;
8888
8989 try {
90- request = new HttpGet (url );
90+ request = new HttpHead (url );
9191 final HttpResponse httpResponse = client .execute (request );
9292
9393 httpEntity = httpResponse .getEntity ();
@@ -118,17 +118,12 @@ final Pair<Integer, String> expandSingleLevelSafe(final String url) throws IOExc
118118 }
119119
120120 final String expandSingleLevel (final String url ) throws IOException {
121- HttpGet request = null ;
122- HttpEntity httpEntity = null ;
123- InputStream entityContentStream = null ;
121+ HttpHead request = null ;
124122
125123 try {
126- request = new HttpGet (url );
124+ request = new HttpHead (url );
127125 final HttpResponse httpResponse = client .execute (request );
128126
129- httpEntity = httpResponse .getEntity ();
130- entityContentStream = httpEntity .getContent ();
131-
132127 final int statusCode = httpResponse .getStatusLine ().getStatusCode ();
133128 if (statusCode != 301 && statusCode != 302 ) {
134129 return url ;
@@ -144,12 +139,6 @@ final String expandSingleLevel(final String url) throws IOException {
144139 if (request != null ) {
145140 request .releaseConnection ();
146141 }
147- if (entityContentStream != null ) {
148- entityContentStream .close ();
149- }
150- if (httpEntity != null ) {
151- EntityUtils .consume (httpEntity );
152- }
153142 }
154143 }
155144
0 commit comments