Skip to content

Commit

Permalink
Merge pull request yasserg#314 from valfirst/use-pre-defined-http-hea…
Browse files Browse the repository at this point in the history
…der-constants

Use pre-defined HTTP header constants
  • Loading branch information
s17t authored Apr 3, 2018
2 parents ab2823c + 0e93a57 commit 3cb4c82
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import javax.net.ssl.SSLContext;

import org.apache.http.Header;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpHost;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
Expand Down Expand Up @@ -277,7 +278,7 @@ public PageFetchResult fetchPage(WebURL webUrl)
statusCode == 308) { // todo follow
// https://issues.apache.org/jira/browse/HTTPCORE-389

Header header = response.getFirstHeader("Location");
Header header = response.getFirstHeader(HttpHeaders.LOCATION);
if (header != null) {
String movedToUrl =
URLCanonicalizer.getCanonicalURL(header.getValue(), toFetchURL);
Expand All @@ -296,7 +297,7 @@ public PageFetchResult fetchPage(WebURL webUrl)
if (fetchResult.getEntity() != null) {
long size = fetchResult.getEntity().getContentLength();
if (size == -1) {
Header length = response.getLastHeader("Content-Length");
Header length = response.getLastHeader(HttpHeaders.CONTENT_LENGTH);
if (length == null) {
length = response.getLastHeader("Content-length");
}
Expand Down

0 comments on commit 3cb4c82

Please sign in to comment.