I am using Grizzly embedded in Spring as a server for Jersey, so my code
is not easily used standalone:
System.setProperty("com.sun.grizzly.util.buf.UDecoder.ALLOW_ENCODED_SLAS
H", "true");
IoCComponentProviderFactory ioCComponentProviderFactory =
new SpringComponentProviderFactory(this.resourceConfig,
(ConfigurableApplicationContext) this.applicationContext);
server =
GrizzlyServerFactory.create(String.format("
http://localhost:%s/",
this.port), resourceConfig, ioCComponentProviderFactory);
However, I guess you guys know the most simple way to spin up a
Grizzly?!
BTW, I have a working fix for the problem:
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 {
if (! result.equals(headers[i].getValue())) {
throw new IllegalArgumentException();
}
}
}
}
return result;
}
Regards,
Adrian
-----Original Message-----
From: Oleksiy.Stashok_at_Sun.COM [mailto:Oleksiy.Stashok_at_Sun.COM]
Sent: 09 December 2009 10:22
To: users_at_grizzly.dev.java.net
Subject: Re: Duplicate Content-Length headers
Hi Adrian,
can you pls. show Grizzly initialization code?
WBR,
Alexey.
On Dec 8, 2009, at 11:20 , adrian.p.smith_at_bt.com wrote:
> 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
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: users-help_at_grizzly.dev.java.net