Skip to content

Commit 48052c6

Browse files
author
邹嵩
committed
修复代理未设置的问题
1 parent 9315ed8 commit 48052c6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/DotnetSpider.Core/Downloader/HttpClientDownloader.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected override async Task<Page> DowloadContent(Request request, ISpider spid
126126
httpClientEntry = HttpClientPool.GetHttpClient(proxy.Hash);
127127
}
128128

129-
PrepareHttpClient(httpClientEntry);
129+
PrepareHttpClient(httpClientEntry, request.Proxy);
130130

131131
response = NetworkCenter.Current.Execute("http", () => httpClientEntry.Client.SendAsync(httpMessage).Result);
132132
request.StatusCode = response.StatusCode;
@@ -192,14 +192,15 @@ protected virtual string ReadContent(Site site, HttpResponseMessage response)
192192
return site.Encoding.GetString(contentBytes, 0, contentBytes.Length);
193193
}
194194

195-
internal void PrepareHttpClient(HttpClientEntry httpClientEntry)
195+
internal void PrepareHttpClient(HttpClientEntry httpClientEntry, IWebProxy proxy)
196196
{
197197
httpClientEntry.Init(AllowAutoRedirect, () =>
198198
{
199199
if (!Equals(httpClientEntry.Client.Timeout.TotalSeconds, _timeout))
200200
{
201201
httpClientEntry.Client.Timeout = new TimeSpan(0, 0, (int)_timeout / 1000);
202202
}
203+
httpClientEntry.Handler.Proxy = proxy;
203204
}, CopyCookieContainer);
204205
}
205206

0 commit comments

Comments
 (0)