atom feed32 messages in org.apache.commons.devRe: [Fwd: [HttpClient][PATCH] Correct...
FromSent OnAttachments
Ryan LubkeJul 10, 2002 11:16 am.patch
robert burrell donkinJul 10, 2002 11:42 am 
Joe GermuskaJul 10, 2002 12:15 pm 
James MitchellJul 10, 2002 12:27 pm 
Craig R. McClanahanJul 10, 2002 12:35 pm 
robert burrell donkinJul 10, 2002 12:49 pm 
Jeff DeverJul 10, 2002 8:52 pm 
di...@multitask.com.auJul 10, 2002 10:30 pm 
Ryan LubkeJul 11, 2002 5:50 am 
Ryan LubkeJul 11, 2002 5:56 am 
Jeff DeverJul 11, 2002 6:00 am 
di...@multitask.com.auJul 11, 2002 6:50 am 
Ortwin GlückJul 11, 2002 6:55 am 
Ryan LubkeJul 11, 2002 7:01 am 
Ryan LubkeJul 11, 2002 7:59 am 
Craig R. McClanahanJul 11, 2002 8:37 am 
Ryan LubkeJul 11, 2002 11:23 am 
David WinterfeldtJul 11, 2002 12:02 pm 
David WinterfeldtJul 11, 2002 12:11 pm 
Craig R. McClanahanJul 11, 2002 1:38 pm 
robert burrell donkinJul 11, 2002 3:07 pm 
di...@multitask.com.auJul 11, 2002 9:57 pm 
di...@multitask.com.auJul 11, 2002 11:25 pm 
David WinterfeldtJul 12, 2002 7:32 am 
Jeff DeverJul 12, 2002 8:17 am 
Ryan LubkeJul 12, 2002 8:26 am 
Rainer KluteJul 12, 2002 8:35 am 
Ola BergJul 13, 2002 1:43 am 
di...@multitask.com.auJul 13, 2002 2:27 am 
di...@multitask.com.auJul 13, 2002 2:27 am 
Rainer KluteJul 13, 2002 6:45 am 
di...@multitask.com.auJul 13, 2002 8:09 pm 
Subject:Re: [Fwd: [HttpClient][PATCH] Correction to addHostRequestHeader +minor formatting cleanups]
From:Jeff Dever (jsde@sympatico.ca)
Date:Jul 10, 2002 8:52:37 pm
List:org.apache.commons.dev

-1 I'd suggest that Ryan re-work a couple things and submit another patch.

rcf2616: A client MUST include a Host header field in all HTTP/1.1 request messages . If the requested URI does not include an Internet host name for the service being requested, then the Host header field MUST be given with an empty value.

So you are saying that because an ipaddress is not an internet host name, the header field must be present but with an empty value. Seems like a reasonable intreptation. Can anyone confirm that?

While you are in the addHostRequestHeader, you might want to take care of that little unlabled todo comment. The host header should only be sent when using HTTP/1.1 and be completely left out for HTTP/1.0. You can search rfc1945 and rfc2616 for "Request Header Fields" to confirm. You can use the http11 boolean variable in a conditional.

For your isIpAddress method, it would have been nice if sun gave us a InetAddress.isIpAddress static method or somthing. But it doesn't see to be convinent to use the InetAddress class. Too bad.

- You may wnat to trim() your input string, else a leading/trailing blank will cause it to return false.

- I think a input value string of 259 sequential "." characters will return true.

- You might be better off using a StringTokenizer and split on the dot. you can then call countTokens() to see if it is in the ball park and then then use Integer.parseInt on the tokens. Return false immeadiately when you find a non-conformity. Still would prefer using some Java.net library method though, but I can't see anything there that would be useful.

- You may also wish to add a test case to TestMethodsNoHost for your isIpAddress method.

Ryan Lubke wrote:

Hello,

I've attached a patch to correct the addHostRequestHeader() method.

The method, as it currently stands, doesn't take into account the fact that the request may be directed at a port other than 80.

Additionally, if the value for the target host is an IP address, the current logic will sent that value across in the Host header, where as, the best I can tell, the 2616 states that if the host value is not an Internet Hostname, then the value for the Host header should be empty.

So the areas of note in the patch are changes to addHostRequestHeader(), and a new private method, isIpAddress(String value).

NOTE: The check performed on the value could be considered weak. All it cares about is that there are 4 all-digit values separated by 3 '.'. If there is a better way to do this, please let me know.

At any rate, I've tested this out and it seems to work OK.

-rl

------------------------------------------------------------------------ Name: HttpMethodBase.java.patch HttpMethodBase.java.patch Type: text/x-patch Encoding: quoted-printable

------------------------------------------------------------------------ -- To unsubscribe, e-mail: <mailto:comm@jakarta.apache.org> For additional commands, e-mail: <mailto:comm@jakarta.apache.org>