CrawlScript / WebCollector

WebCollector is an open source web crawler framework based on Java.It provides some simple interfaces for crawling the Web,you can setup a multi-threaded web crawler in less than 5 minutes.
https://github.com/CrawlScript/WebCollector
GNU General Public License v3.0
3.07k stars 1.45k forks source link

2.70版本HttpRequest中的setUserAgent()方法无效 #72

Closed yanzuo1992 closed 6 years ago

yanzuo1992 commented 7 years ago

在执行setUserAgent()时,会执行setHeader() 但是setHeader()并不会更新this.userAgent 在2.70版本HttpRequest的response()中会执行 if (this.userAgent != null) { this.setUserAgent(this.userAgent); } 因为this.userAgent为默认值,且setUserAgent又没有更新此值 导致设置的UA不生效

yxssfxwzy commented 6 years ago

好像是有这个问题

mdzz9527 commented 6 years ago

这个怎么解决呢?

mdzz9527 commented 6 years ago

我设置了setUserAgent() 然而我执行了getUserAgent()的方法,但是返回的并不是我设置的UserAgent();

dick28cm commented 6 years ago

确实无效的哦. 只能重写这个方法

dick28cm commented 6 years ago
@Override
public void setUserAgent(String userAgent) {
    this.userAgent = userAgent;
    setHeader("User-Agent", this.userAgent);
}
hujunxianligong commented 6 years ago

不好意思,老版本的Bug,新版本现在修复了。