...ext.http.HttpRequest#parseHeader does not work
Brought to you by:
jm7
Current implementation uses StringTokenizer with colon as delimiter an suppose that value could not have colon. So next header would not be parsed:
user-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2
key would be 'user-agent'
value would be 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv' which is not correct.
Suggested replacement for the method
Logged In: YES
user_id=1767333
Originator: NO
You bet me to it... like a month ago -___-
Here's my fix:
<pre>
private void parseHeader() {
if (rawHeader == null) return;
header = new Hashtable(1);
for (int i = 0; i < rawHeader.size(); i++) {
String h = (String) rawHeader.elementAt(i);
// RF: The following code is buggy; it doesn't support strings with
// embedded colons.
/* StringTokenizer s = new StringTokenizer(h);
* String k = s.nextToken(":").trim();
* String v = s.nextToken().trim(); */
String[] kv = h.split(":", 2);
String k = kv[0].trim();
String v = kv[1].trim();
if (DEBUG) System.err.println("httpRequest: key=" + k + ", val=" + v);
header.put(k, v);
}
}
</pre>
Replace parseHeader() in HttpRequest.java with this.