Commit 5a226387 authored by yihua.huang's avatar yihua.huang

#27 nullpointer fix

parent 16e12e3b
...@@ -51,9 +51,14 @@ public class HttpClientPool { ...@@ -51,9 +51,14 @@ public class HttpClientPool {
HttpParams params = new BasicHttpParams(); HttpParams params = new BasicHttpParams();
if (site != null && site.getUserAgent() != null) { if (site != null && site.getUserAgent() != null) {
params.setParameter(CoreProtocolPNames.USER_AGENT, site.getUserAgent()); params.setParameter(CoreProtocolPNames.USER_AGENT, site.getUserAgent());
params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, site.getTimeOut());
params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, site.getTimeOut());
} else {
params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 3000);
params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
} }
params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, site.getTimeOut());
params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, site.getTimeOut());
params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH); params.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.BEST_MATCH);
HttpProtocolParamBean paramsBean = new HttpProtocolParamBean(params); HttpProtocolParamBean paramsBean = new HttpProtocolParamBean(params);
paramsBean.setVersion(HttpVersion.HTTP_1_1); paramsBean.setVersion(HttpVersion.HTTP_1_1);
...@@ -73,7 +78,6 @@ public class HttpClientPool { ...@@ -73,7 +78,6 @@ public class HttpClientPool {
if (site != null) { if (site != null) {
generateCookie(httpClient, site); generateCookie(httpClient, site);
} }
return httpClient; return httpClient;
} }
......
...@@ -22,4 +22,5 @@ public class HttpClientDownloaderTest { ...@@ -22,4 +22,5 @@ public class HttpClientDownloaderTest {
Page download = httpClientDownloader.download(new Request("http://www.diandian.com"), site.toTask()); Page download = httpClientDownloader.download(new Request("http://www.diandian.com"), site.toTask());
Assert.assertTrue(download.getHtml().toString().contains("flashsword30")); Assert.assertTrue(download.getHtml().toString().contains("flashsword30"));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment