users@grizzly.java.net

RE: Duplicate Content-Length headers

From: <adrian.p.smith_at_bt.com>
Date: Tue, 8 Dec 2009 10:20:40 -0000

Hubert,

Here is a simple unit test to run against a running server.

    @Test
    public void testDoubleContentLengthHeaders() throws Exception {
        HttpClient httpClient = new HttpClient();
        PutMethod putMethod = new PutMethod("http://localhost:9090");
        putMethod.addRequestHeader("Content-Length", "0");
        putMethod.addRequestHeader("content-length", "0");

        int rc = httpClient.executeMethod(putMethod);
        System.out.println(rc);

        assertFalse(400 == rc);
    }

I think the Grizzly code in question is somewhere around
com.sun.grizzly.util.http.MimeHeaders.java

    /**
     * Finds and returns a unique header field with the given name. If
no such
     * field exists, null is returned. If the specified header field is
not
     * unique then an {_at_link IllegalArgumentException} is thrown.
     */
    public MessageBytes getUniqueValue(String name) {
        MessageBytes result = null;
        for (int i = 0; i < count; i++) {
            if (headers[i].getName().equalsIgnoreCase(name)) {
                if (result == null) {
                    result = headers[i].getValue();
                } else {
                    throw new IllegalArgumentException();
                }
            }
        }
        return result;
    }


Which results in a 400 BAD_REQUEST response?

Does this make sense?

Regards,

Adrian









-----Original Message-----
From: Hubert Iwaniuk [mailto:neotyk_at_kungfoo.pl]
Sent: 08 December 2009 09:32
To: users_at_grizzly.dev.java.net
Subject: Re: Duplicate Content-Length headers

Hi Adrian,

Can you provide a sample to reproduce this issue.

Thanks,
Hubert



On Tue, Dec 8, 2009 at 9:36 AM, <adrian.p.smith_at_bt.com> wrote:
> I notice that Grizzly rejects requests with more than one
Content-Length
>
> header.
>
>
>
> I understand why this is done, but could the team consider an
>
> alternative strategy?
>
>
>
> Could the server be made to accept these requests, providing the
values
>
> for content-length are identical?
>
>
>
> I have some legacy clients that I cannot change and this is making it
>
> hard for me to choose Grizzly as my prefered server.
>
>
>
> TIA.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net