hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vasudevan Comandur <vcoman...@gmail.com>
Subject Re: What is the right procedure to setting the User-Agent request header to masquerade HttpClient as a popular browser ?
Date Wed, 15 Sep 2010 13:51:54 GMT
Check if the below string will solve your problem

"Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-US; rv:
Gecko/2008092414 Firefox/3.0.3"


On Wed, Sep 15, 2010 at 6:51 PM, F.Berg <freakzoidberg@me.com> wrote:

> Hi all,
> We are dealing with the following issue.  We are using a tomcat server with
> Vyre to access source material that needs to be streamed, but since the
> client library / User-agent is identifying it self with the default Jakarta
> Commons-HttpClient/3.1 tag when connecting to the other site, the connection
> gets blocked and will not be unblocked unless we can send alternative
> User-Agent profile to the source.   See relevant message from the the site
> admin :
> "The client library your software is using to download the XML is
> identifying itself as "Jakarta Commons-HttpClient/3.1". This is the default
> User-Agent of a library commonly used with crawlers. You'll need to change
> the User-Agent to get unblocked. "
> From searching for a solution and from item 5 in the things to try list *on
> the apache.org site*<http://hc.apache.org/httpclient-3.x/troubleshooting.html>and
other issues where this
> *solution *<http://www.mail-archive.com/httpclient-user@jakarta.apache.org/msg04444.html>has
> been used, we know there is a way to do this.  But have not found clear
> instruction on just what you need to do in order to make this change, just
> suggestions that you make the change without explaining how make this change
> in a straightforward manner.    There are is a number of hints that I have
> found as to what text parameters you need to change, such as the one below,
> but have not been able to find exactly which file or scrip needs to be
> edited in order to make this change.  Everything indicates this should be a
> reasonably simple procedure.
> I would be grateful if someone that has successfully implemented this
> change could let us know what is the right procedure to do this.  Is the
> only way to do this to edit the
> org/apache/commons/httpclient/params/HttpMethodParams.class file and
> recompile the source ?   Or is there a simpler way of setting the User_Agent
> request header to masquerde the HttpClient  that that ?
> import org.apache.commons.httpclient.HttpClient;
> import org.apache.commons.httpclient.params.HttpMethodParams;
> ...
> HttpClient httpclient = new HttpClient();
> httpclient.getParams().setParameter(HttpMethodParams.USER_AGENT,
>     "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
> ...
> Cheers,
> Sveinn
> Confucius said: "To study and not think is a waste. To think and not study is dangerous."

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message