Skip to main content

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

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...

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


Back to the top