Skip to content

Commit 462c60f

Browse files
committed
Fix for entity is null.
1 parent 54aef0f commit 462c60f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientDownloader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public void setThread(int thread) {
103103

104104
protected Page handleResponse(Request request, String charset, HttpResponse httpResponse, Task task) throws IOException {
105105
HttpEntity entity = httpResponse.getEntity();
106-
byte[] bytes = entity != null ? IOUtils.toByteArray(entity.getContent()) : new byte[0];;
107-
String contentType = httpResponse.getEntity().getContentType() == null ? "" : httpResponse.getEntity().getContentType().getValue();
106+
byte[] bytes = entity != null ? IOUtils.toByteArray(entity.getContent()) : new byte[0];
107+
String contentType = entity != null && entity.getContentType() != null ? entity.getContentType().getValue() : null;
108108
Page page = new Page();
109109
page.setBytes(bytes);
110110
if (!request.isBinaryContent()) {

0 commit comments

Comments
 (0)