You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Michael Andresen (JIRA)" <ji...@apache.org> on 2010/02/19 00:21:28 UTC

[jira] Updated: (HARMONY-6452) HttpUrlConnection converts request headers to lowercase - HttpUrlConnection.addRequestProperty overrides existing properties

     [ https://issues.apache.org/jira/browse/HARMONY-6452?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Andresen updated HARMONY-6452:
--------------------------------------

    Description: 
Problem: Lower-Case-Headers
==============================
In Sun's JRE this code
	java.net.HttpURLConnection conn = (java.net.HttpURLConnection)(new java.net.URL("http://...").openConnection());
	conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=...");
	System.out.println (conn.getRequestProperty("content-type"));
	System.out.println (conn.getRequestProperties());
produces the following output:
	multipart/form-data; boundary=...
	{Content-Type=[multipart/form-data; boundary=...]}
The Property-Name "Content-Type" is stored case sensitive but it can be fetched in lower-case.
The resulting Request-Header sent to the Web-Server is case sensitive.

On Android 1.6 (which uses Apache Harmony) the same Code produces the following output:
	multipart/form-data; boundary=...
	{content-type=[multipart/form-data; boundary=...]}
This time the Property-Name "Content-Type" is stored in lower-case. The resulting Request-Header is also sent in lower-case. That's a violation of the HTTP 1.1 spec, and certain service providers may ignore such Request-Headers.

In harmony 5.0 r901653 the output is the same as on Android 1.6 but the resulting Request-Header is sent case-sensitive.

Problem addRequestProperty overrides existing properties
==============================================
Existing Properties should be appended.

Example
==============================================
	HttpURLConnection conn = (HttpURLConnection)(new URL("http://www.example.com/index.html").openConnection());
	conn.setRequestProperty("content-disposition", "Content-Disposition: form-data");
	conn.addRequestProperty("content-disposition", "name=\"file\"");
	conn.addRequestProperty("content-disposition", "filename=\"test.html\"");
	conn.setRequestProperty("a", "1");
	conn.addRequestProperty("a", "2");
	System.out.println ("Single Property: "+conn.getRequestProperty("content-disposition"));
	System.out.println ("All Properties:");
	for (Map.Entry<String, List<String>> entry : conn.getRequestProperties().entrySet()) {
		System.out.print ("  Property: "+entry.getKey()+" = {");
		for (String v : entry.getValue())
			System.out.print (v+";");
		System.out.println ("}");
	}
Should produce the following output:
	Single Property: filename="test.html"
	All Properties:
	  Property: a = {2;1;}
	  Property: content-disposition = {filename="test.html";name="file";Content-Disposition: form-data;}
But the following output is produced:
	Single Property: filename="test.html"
	All Properties:
	  Property: content-disposition = {filename="test.html";}
	  Property: a = {2;}
I have set the Property "Content-Disposition" in lower-case to make clear, that this problem is independent of the lower-case headers problem.


Info
==============================================
The class org.apache.harmony.luni.internal.net.www.protocol.http.Header is not correct implemented. It only works with lower-case property-names and each property-value can only contain one entry.

Question
==============================
1. Does anybody know how to find out which version of harmony is used by Android 1.6? I tried System.getProperties() but that didn't help.


  was:
Problem: Lower-Case-Headers
==============================
In Sun's JRE this code
	java.net.HttpURLConnection conn = (java.net.HttpURLConnection)(new java.net.URL("http://...").openConnection());
	conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=...");
	System.out.println (conn.getRequestProperty("content-type"));
	System.out.println (conn.getRequestProperties());
produces the following output:
	multipart/form-data; boundary=...
	{Content-Type=[multipart/form-data; boundary=...]}
The Property-Name "Content-Type" is stored case sensitive but it can be fetched in lower-case.
The resulting Request-Header sent to the Web-Server is case sensitive.

On Android 1.6 (which uses Apache Harmony) the same Code produces the following output:
	multipart/form-data; boundary=...
	{content-type=[multipart/form-data; boundary=...]}
This time the Property-Name "Content-Type" is stored in lower-case. The resulting Request-Header is also sent in lower-case. That's a violation of the HTTP 1.1 spec, and certain service providers may ignore such Request-Headers.

In harmony 5.0 r901653 the output is the same as on Android 1.6 but the resulting Request-Header is sent case-sensitive.

Problem addRequestProperty overrides existing properties
==============================================
Existing Properties should be appended.


Info
==============================================
The class org.apache.harmony.luni.internal.net.www.protocol.http.Header is not correct implemented. It only works with lower-case property-names and each property-value can only contain one entry.

Question
==============================
1. Does anybody know how to find out which version of harmony is used by Android 1.6? I tried System.getProperties() but that didn't help.
2. I would like to attach a patch to this issue but I don't know how? Simply copy it into the Description? Is there a File-Upload?


- Added an example for the replaced property problem
- Removed the question howto attach a patch file - thanks to Mark Hindess

> HttpUrlConnection converts request headers to lowercase - HttpUrlConnection.addRequestProperty overrides existing properties
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6452
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6452
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Android 1.6
>            Reporter: Michael Andresen
>            Assignee: Mark Hindess
>
> Problem: Lower-Case-Headers
> ==============================
> In Sun's JRE this code
> 	java.net.HttpURLConnection conn = (java.net.HttpURLConnection)(new java.net.URL("http://...").openConnection());
> 	conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=...");
> 	System.out.println (conn.getRequestProperty("content-type"));
> 	System.out.println (conn.getRequestProperties());
> produces the following output:
> 	multipart/form-data; boundary=...
> 	{Content-Type=[multipart/form-data; boundary=...]}
> The Property-Name "Content-Type" is stored case sensitive but it can be fetched in lower-case.
> The resulting Request-Header sent to the Web-Server is case sensitive.
> On Android 1.6 (which uses Apache Harmony) the same Code produces the following output:
> 	multipart/form-data; boundary=...
> 	{content-type=[multipart/form-data; boundary=...]}
> This time the Property-Name "Content-Type" is stored in lower-case. The resulting Request-Header is also sent in lower-case. That's a violation of the HTTP 1.1 spec, and certain service providers may ignore such Request-Headers.
> In harmony 5.0 r901653 the output is the same as on Android 1.6 but the resulting Request-Header is sent case-sensitive.
> Problem addRequestProperty overrides existing properties
> ==============================================
> Existing Properties should be appended.
> Example
> ==============================================
> 	HttpURLConnection conn = (HttpURLConnection)(new URL("http://www.example.com/index.html").openConnection());
> 	conn.setRequestProperty("content-disposition", "Content-Disposition: form-data");
> 	conn.addRequestProperty("content-disposition", "name=\"file\"");
> 	conn.addRequestProperty("content-disposition", "filename=\"test.html\"");
> 	conn.setRequestProperty("a", "1");
> 	conn.addRequestProperty("a", "2");
> 	System.out.println ("Single Property: "+conn.getRequestProperty("content-disposition"));
> 	System.out.println ("All Properties:");
> 	for (Map.Entry<String, List<String>> entry : conn.getRequestProperties().entrySet()) {
> 		System.out.print ("  Property: "+entry.getKey()+" = {");
> 		for (String v : entry.getValue())
> 			System.out.print (v+";");
> 		System.out.println ("}");
> 	}
> Should produce the following output:
> 	Single Property: filename="test.html"
> 	All Properties:
> 	  Property: a = {2;1;}
> 	  Property: content-disposition = {filename="test.html";name="file";Content-Disposition: form-data;}
> But the following output is produced:
> 	Single Property: filename="test.html"
> 	All Properties:
> 	  Property: content-disposition = {filename="test.html";}
> 	  Property: a = {2;}
> I have set the Property "Content-Disposition" in lower-case to make clear, that this problem is independent of the lower-case headers problem.
> Info
> ==============================================
> The class org.apache.harmony.luni.internal.net.www.protocol.http.Header is not correct implemented. It only works with lower-case property-names and each property-value can only contain one entry.
> Question
> ==============================
> 1. Does anybody know how to find out which version of harmony is used by Android 1.6? I tried System.getProperties() but that didn't help.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.