HttpClient and User Agent string

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

HttpClient and User Agent string

Luca Passani
Hello

the archives contain traces of a HttpClient specific dev mailing list,
but it does not seem to exist anymore, so I wonder if this is the right
place to ask.

I need to build some HTTP utilities. Jakarta HttpClient seemed
to do the job apparently, but I can't find a way to change the
user-agent header!!!

reading the JavaDocs I got as far as:

getmethod = new GetMethod(url_to_get);
Header ua = new Header("User-Agent","Mozilla/5.0 (Macintosh; U; PPC Mac
OS X; en)");
getmethod.USER_AGENT = ua;

Alas, for reasons I can't understand, this is not permitted:

    [javac] DocumentRetriever.java:110: USER_AGENT has protected access
in org.apache.commons.httpclient.HttpMethodBase
    [javac]         getmethod.USER_AGENT = ua;
    [javac]                      ^
    [javac] 1 error

what am I missing?

thanks

luca


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[httpclient]Re: HttpClient and User Agent string

Brian K. Wallace
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Luca -

Httpclient's list is [hidden email] but if you send
to commons-user, please prefix your messages with [httpclient] as most
people filter based on the component.

Try
~  getmethod.setRequestHeader(ua);

Hope that helps.

Brian

Luca Passani wrote:
| Hello
|
| the archives contain traces of a HttpClient specific dev mailing list,
| but it does not seem to exist anymore, so I wonder if this is the right
| place to ask.
|
| I need to build some HTTP utilities. Jakarta HttpClient seemed
| to do the job apparently, but I can't find a way to change the
| user-agent header!!!
|
| reading the JavaDocs I got as far as:
|
| getmethod = new GetMethod(url_to_get);
| Header ua = new Header("User-Agent","Mozilla/5.0 (Macintosh; U; PPC Mac
| OS X; en)");
| getmethod.USER_AGENT = ua;
|
| Alas, for reasons I can't understand, this is not permitted:
|
|    [javac] DocumentRetriever.java:110: USER_AGENT has protected access
| in org.apache.commons.httpclient.HttpMethodBase
|    [javac]         getmethod.USER_AGENT = ua;
|    [javac]                      ^
|    [javac] 1 error
|
| what am I missing?
|
| thanks
|
| luca
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: [hidden email]
| For additional commands, e-mail: [hidden email]
|
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)

iD8DBQFCjSKqaCoPKRow/gARApgMAJ9EZLaUmc9wnsDFIBIBdDZJMgTSIgCcChhU
2jan9gGPwtAj0VtNMox4Csc=
=Z+YX
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: HttpClient and User Agent string

Mattias Jiderhamn-2
In reply to this post by Luca Passani
At 2005-05-20 00:32, you wrote:

>Hello
>
>the archives contain traces of a HttpClient specific dev mailing list, but
>it does not seem to exist anymore, so I wonder if this is the right place
>to ask.
>
>I need to build some HTTP utilities. Jakarta HttpClient seemed
>to do the job apparently, but I can't find a way to change the
>user-agent header!!!
>
>reading the JavaDocs I got as far as:
>
>getmethod = new GetMethod(url_to_get);
>Header ua = new Header("User-Agent","Mozilla/5.0 (Macintosh; U; PPC Mac OS
>X; en)");
>getmethod.USER_AGENT = ua;
>
>Alas, for reasons I can't understand, this is not permitted:

What about addUserAgentRequestHeader()...?



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

R: HttpClient and User Agent string

Andrea Sodomaco
In reply to this post by Luca Passani
Try

getmethod = new GetMethod(url_to_get);
Header ua = new Header("User-Agent","Mozilla/5.0 (Macintosh; U; PPC Mac
OS X; en)");
getmethod.setRequestHeader(ua);

Andrea


-----Messaggio originale-----
Da: Luca Passani [mailto:[hidden email]]
Inviato: venerdì 20 maggio 2005 0.33
A: [hidden email]
Oggetto: HttpClient and User Agent string

Hello

the archives contain traces of a HttpClient specific dev mailing list,
but it does not seem to exist anymore, so I wonder if this is the right
place to ask.

I need to build some HTTP utilities. Jakarta HttpClient seemed
to do the job apparently, but I can't find a way to change the
user-agent header!!!

reading the JavaDocs I got as far as:

getmethod = new GetMethod(url_to_get);
Header ua = new Header("User-Agent","Mozilla/5.0 (Macintosh; U; PPC Mac
OS X; en)");
getmethod.USER_AGENT = ua;

Alas, for reasons I can't understand, this is not permitted:

    [javac] DocumentRetriever.java:110: USER_AGENT has protected access
in org.apache.commons.httpclient.HttpMethodBase
    [javac]         getmethod.USER_AGENT = ua;
    [javac]                      ^
    [javac] 1 error

what am I missing?

thanks

luca


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: HttpClient and User Agent string

Mattias Jiderhamn-2
In reply to this post by Mattias Jiderhamn-2
At 2005-05-20 08:10, you wrote:

>At 2005-05-20 00:32, you wrote:
>>Hello
>>
>>the archives contain traces of a HttpClient specific dev mailing list,
>>but it does not seem to exist anymore, so I wonder if this is the right
>>place to ask.
>>
>>I need to build some HTTP utilities. Jakarta HttpClient seemed
>>to do the job apparently, but I can't find a way to change the
>>user-agent header!!!
>>
>>reading the JavaDocs I got as far as:
>>
>>getmethod = new GetMethod(url_to_get);
>>Header ua = new Header("User-Agent","Mozilla/5.0 (Macintosh; U; PPC Mac
>>OS X; en)");
>>getmethod.USER_AGENT = ua;
>>
>>Alas, for reasons I can't understand, this is not permitted:
>
>What about addUserAgentRequestHeader()...?

(I was too hasty to note it was also protected. Sorry!
  Just use Andrea Sodomacos instructions)


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: HttpClient and User Agent string

Luca Passani
Mattias J wrote:

>>
>> What about addUserAgentRequestHeader()...?
>
>
> (I was too hasty to note it was also protected. Sorry!
>  Just use Andrea Sodomacos instructions)

First off, thank you to everyone who helped. It worked.

wrt to this messgae,  you have a point. the existance of that method was
the one that confused me too.
I had assumed that for HttpClient, User Agent was a special header and
not an header like the others.

Luca


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]