Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] jetty-client: don't send default User-Agent field

@sbordet, because the Request code only replaces the UA if it is non null on the HttpClient.  So they want to set it to null so it doesn't replace the original UA. But setter can't handle null 

On 23 Sep 2017 20:16, "Simone Bordet" <sbordet@xxxxxxxxxxx> wrote:
Hi,

On Fri, Sep 22, 2017 at 6:40 PM, Steven Schlansker
<stevenschlansker@xxxxxxxxx> wrote:
> Hi jetty-users,
>
> I am writing a HTTP proxy that calls remote services by jetty-client.
> I do not want the proxy to modify user agent headers, it should be whatever
> the incoming request says (we do UA-detection on the far side).
>
> HttpRequest does something reasonable:
>
>     HttpField userAgentField = client.getUserAgentField();
>     if (userAgentField != null)
>         headers.put(userAgentField);
>
> but HttpClient says no:
>
>     public void setUserAgentField(HttpField agent)
>     {
>         if (agent.getHeader() != HttpHeader.USER_AGENT)
>             throw new IllegalArgumentException();
>         this.agentField = agent;
>     }
>
> throws NPE.
>
> What's the right way to have the client not muck with UA?  Should we
> relax the setter to allow setUserAgentField(null)?  I can subclass
> but that's a little obnoxious just for this...

I don't understand.
The user agent you set on HttpClient would be the default one to use.
Why are you calling httpClient.setUserAgentField(null) ?

--
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

Back to the top