Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webmagic
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
沈俊林
webmagic
Commits
ed3f3583
Commit
ed3f3583
authored
Nov 03, 2013
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
downloader refactor
parent
a37f40e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
5 deletions
+5
-5
HttpClientDownloader.java
...s/codecraft/webmagic/downloader/HttpClientDownloader.java
+2
-2
HttpClientGenerator.java
...us/codecraft/webmagic/downloader/HttpClientGenerator.java
+2
-2
HttpClientPool-cmnt.xml
.../us/codecraft/webmagic/downloader/HttpClientPool-cmnt.xml
+1
-1
No files found.
webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientDownloader.java
View file @
ed3f3583
...
@@ -63,14 +63,14 @@ public class HttpClientDownloader implements Downloader {
...
@@ -63,14 +63,14 @@ public class HttpClientDownloader implements Downloader {
private
CloseableHttpClient
getHttpClient
(
Site
site
)
{
private
CloseableHttpClient
getHttpClient
(
Site
site
)
{
if
(
site
==
null
)
{
if
(
site
==
null
)
{
return
new
HttpClient
Pool
(
poolSize
).
getClient
(
null
);
return
new
HttpClient
Generator
(
poolSize
).
getClient
(
null
);
}
}
String
domain
=
site
.
getDomain
();
String
domain
=
site
.
getDomain
();
CloseableHttpClient
httpClient
=
httpClients
.
get
(
domain
);
CloseableHttpClient
httpClient
=
httpClients
.
get
(
domain
);
if
(
httpClient
==
null
)
{
if
(
httpClient
==
null
)
{
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
httpClient
==
null
)
{
if
(
httpClient
==
null
)
{
httpClient
=
new
HttpClient
Pool
(
poolSize
).
getClient
(
site
);
httpClient
=
new
HttpClient
Generator
(
poolSize
).
getClient
(
site
);
httpClients
.
put
(
domain
,
httpClient
);
httpClients
.
put
(
domain
,
httpClient
);
}
}
}
}
...
...
webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClient
Pool
.java
→
webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClient
Generator
.java
View file @
ed3f3583
...
@@ -21,11 +21,11 @@ import java.util.Map;
...
@@ -21,11 +21,11 @@ import java.util.Map;
* @author code4crafter@gmail.com <br>
* @author code4crafter@gmail.com <br>
* @since 0.3.3
* @since 0.3.3
*/
*/
public
class
HttpClient
Pool
{
public
class
HttpClient
Generator
{
private
PoolingHttpClientConnectionManager
connectionManager
;
private
PoolingHttpClientConnectionManager
connectionManager
;
public
HttpClient
Pool
(
int
poolSize
)
{
public
HttpClient
Generator
(
int
poolSize
)
{
Registry
<
ConnectionSocketFactory
>
reg
=
RegistryBuilder
.<
ConnectionSocketFactory
>
create
()
Registry
<
ConnectionSocketFactory
>
reg
=
RegistryBuilder
.<
ConnectionSocketFactory
>
create
()
.
register
(
"http"
,
PlainConnectionSocketFactory
.
INSTANCE
)
.
register
(
"http"
,
PlainConnectionSocketFactory
.
INSTANCE
)
.
register
(
"https"
,
SSLConnectionSocketFactory
.
getSocketFactory
())
.
register
(
"https"
,
SSLConnectionSocketFactory
.
getSocketFactory
())
...
...
zh_docs/us/codecraft/webmagic/downloader/HttpClientPool-cmnt.xml
View file @
ed3f3583
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<date-generated>
Sat Aug 17 14:14:45 CST 2013
</date-generated>
<date-generated>
Sat Aug 17 14:14:45 CST 2013
</date-generated>
</meta>
</meta>
<comment>
<comment>
<key>
<![CDATA[us.codecraft.webmagic.downloader.HttpClient
Pool
]]>
</key>
<key>
<![CDATA[us.codecraft.webmagic.downloader.HttpClient
Generator
]]>
</key>
<data>
<![CDATA[ @author code4crafter@gmail.com <br>
<data>
<![CDATA[ @author code4crafter@gmail.com <br>
Date: 13-4-21
Date: 13-4-21
Time: 下午12:29
Time: 下午12:29
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment