hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject httpcomponents-client git commit: Deprecated Content-Transfer-Encoding field in MIME body parts per RFC 7578, section 4.7
Date Sat, 30 Sep 2017 21:43:36 GMT
Repository: httpcomponents-client
Updated Branches:
  refs/heads/4.6.x 278e47d27 -> 5a44282ca


Deprecated Content-Transfer-Encoding field in MIME body parts per RFC 7578, section 4.7


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/5a44282c
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/5a44282c
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/5a44282c

Branch: refs/heads/4.6.x
Commit: 5a44282cac7f1c21243447c177de60f556645b18
Parents: 278e47d
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Sat Sep 30 23:35:41 2017 +0200
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Sat Sep 30 23:41:55 2017 +0200

----------------------------------------------------------------------
 .../http/entity/mime/FormBodyPartBuilder.java       |  4 ----
 .../main/java/org/apache/http/entity/mime/MIME.java |  4 ++++
 .../http/entity/mime/content/ByteArrayBody.java     |  1 +
 .../http/entity/mime/content/ContentDescriptor.java |  3 +++
 .../http/entity/mime/TestFormBodyPartBuilder.java   | 16 ++++++----------
 .../http/entity/mime/TestMultipartContentBody.java  |  4 ----
 .../entity/mime/TestMultipartEntityBuilder.java     |  2 --
 .../apache/http/entity/mime/TestMultipartForm.java  | 15 ---------------
 8 files changed, 14 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java
----------------------------------------------------------------------
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java
index cb3e584..761e08d 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPartBuilder.java
@@ -139,10 +139,6 @@ public class FormBodyPartBuilder {
                 headerCopy.addField(new MinimalField(MIME.CONTENT_TYPE, buffer.toString()));
             }
         }
-        if (headerCopy.getField(MIME.CONTENT_TRANSFER_ENC) == null) {
-            // TE cannot be null
-            headerCopy.addField(new MinimalField(MIME.CONTENT_TRANSFER_ENC, body.getTransferEncoding()));
-        }
         return new FormBodyPart(this.name, this.body, headerCopy);
     }
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java
----------------------------------------------------------------------
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java b/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java
index e4df389..fe84db4 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/MIME.java
@@ -38,6 +38,10 @@ import org.apache.http.Consts;
 public final class MIME {
 
     public static final String CONTENT_TYPE          = "Content-Type";
+    /**
+     * @deprecated Deprecated per RFC 7578, section 4.7. Do not use
+     */
+    @Deprecated
     public static final String CONTENT_TRANSFER_ENC  = "Content-Transfer-Encoding";
     public static final String CONTENT_DISPOSITION   = "Content-Disposition";
 

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
----------------------------------------------------------------------
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
b/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
index d73e5ce..01ebbc4 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
@@ -103,6 +103,7 @@ public class ByteArrayBody extends AbstractContentBody {
     }
 
     @Override
+    @Deprecated
     public String getTransferEncoding() {
         return MIME.ENC_BINARY;
     }

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/main/java/org/apache/http/entity/mime/content/ContentDescriptor.java
----------------------------------------------------------------------
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/ContentDescriptor.java
b/httpmime/src/main/java/org/apache/http/entity/mime/content/ContentDescriptor.java
index 6bbfdc9..a174f6f 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/ContentDescriptor.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/ContentDescriptor.java
@@ -76,7 +76,10 @@ public interface ContentDescriptor {
      * Returns the body descriptors transfer encoding.
      * @return The transfer encoding. Must not be null, but "7bit",
      *   if no transfer-encoding was specified.
+     *
+     * @deprecated Deprecated per RFC 7578, section 4.7. Do not use
      */
+    @Deprecated
     String getTransferEncoding();
 
     /**

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
----------------------------------------------------------------------
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
b/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
index 81b7e1f..0535736 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
@@ -30,6 +30,7 @@ package org.apache.http.entity.mime;
 import java.io.File;
 import java.util.Arrays;
 import java.util.List;
+
 import org.apache.http.entity.ContentType;
 import org.apache.http.entity.mime.content.FileBody;
 import org.apache.http.entity.mime.content.StringBody;
@@ -52,8 +53,7 @@ public class TestFormBodyPartBuilder {
         Assert.assertNotNull(header);
         assertFields(Arrays.asList(
                         new MinimalField("Content-Disposition", "form-data; name=\"blah\""),
-                        new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1"),
-                        new MinimalField("Content-Transfer-Encoding", "8bit")),
+                        new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1")),
                 header.getFields());
     }
 
@@ -72,8 +72,7 @@ public class TestFormBodyPartBuilder {
         Assert.assertNotNull(header1);
         assertFields(Arrays.asList(
                         new MinimalField("Content-Disposition", "form-data; name=\"blah\""),
-                        new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1"),
-                        new MinimalField("Content-Transfer-Encoding", "8bit")),
+                        new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1")),
                 header1.getFields());
         final FileBody fileBody = new FileBody(new File("/path/stuff.bin"), ContentType.DEFAULT_BINARY);
         final FormBodyPart bodyPart2 = builder
@@ -88,8 +87,7 @@ public class TestFormBodyPartBuilder {
         Assert.assertNotNull(header2);
         assertFields(Arrays.asList(
                         new MinimalField("Content-Disposition", "form-data; name=\"yada\";
filename=\"stuff.bin\""),
-                        new MinimalField("Content-Type", "application/octet-stream"),
-                        new MinimalField("Content-Transfer-Encoding", "binary")),
+                        new MinimalField("Content-Type", "application/octet-stream")),
                 header2.getFields());
     }
 
@@ -118,8 +116,7 @@ public class TestFormBodyPartBuilder {
                 new MinimalField("header3", "blah"),
                 new MinimalField("header3", "blah"),
                 new MinimalField("Content-Disposition", "form-data; name=\"blah\""),
-                new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1"),
-                new MinimalField("Content-Transfer-Encoding", "8bit")),
+                new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1")),
                 header1.getFields());
 
         final FormBodyPart bodyPart2 = builder
@@ -135,8 +132,7 @@ public class TestFormBodyPartBuilder {
                         new MinimalField("header1", "blah"),
                         new MinimalField("header2", "yada"),
                         new MinimalField("Content-Disposition", "form-data; name=\"blah\""),
-                        new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1"),
-                        new MinimalField("Content-Transfer-Encoding", "8bit")),
+                        new MinimalField("Content-Type", "text/plain; charset=ISO-8859-1")),
                 header2.getFields());
 
         final FormBodyPart bodyPart3 = builder

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
----------------------------------------------------------------------
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
index 6c5a6e2..5ed7d2c 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
@@ -87,8 +87,6 @@ public class TestMultipartContentBody {
         Assert.assertEquals("application", b1.getMediaType());
         Assert.assertEquals("octet-stream", b1.getSubType());
 
-        Assert.assertEquals(MIME.ENC_BINARY, b1.getTransferEncoding());
-
         final InputStreamBody b2 = new InputStreamBody(
                 new ByteArrayInputStream(stuff), ContentType.create("some/stuff"), "stuff");
         Assert.assertEquals(-1, b2.getContentLength());
@@ -97,8 +95,6 @@ public class TestMultipartContentBody {
         Assert.assertEquals("some/stuff", b2.getMimeType());
         Assert.assertEquals("some", b2.getMediaType());
         Assert.assertEquals("stuff", b2.getSubType());
-
-        Assert.assertEquals(MIME.ENC_BINARY, b2.getTransferEncoding());
     }
 
 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
----------------------------------------------------------------------
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
index 33f28f2..2046d6a 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
@@ -149,7 +149,6 @@ public class TestMultipartEntityBuilder {
         Assert.assertEquals("--xxxxxxxxxxxxxxxxxxxxxxxx\r\n" +
                 "Content-Disposition: multipart/form-data; name=\"test\"; filename=\"hello
world\"\r\n" +
                 "Content-Type: text/plain; charset=ISO-8859-1\r\n" +
-                "Content-Transfer-Encoding: 8bit\r\n" +
                 "\r\n" +
                 "hello world\r\n" +
                 "--xxxxxxxxxxxxxxxxxxxxxxxx--\r\n", out.toString(Consts.ASCII.name()));
@@ -176,7 +175,6 @@ public class TestMultipartEntityBuilder {
         Assert.assertEquals("--xxxxxxxxxxxxxxxxxxxxxxxx\r\n" +
                 "Content-Disposition: multipart/form-data; name=\"test\"; filename=\"hello%20%CE%BA%CF%8C%CF%83%CE%BC%CE%B5!%25\"\r\n"
+
                 "Content-Type: text/plain; charset=ISO-8859-1\r\n" +
-                "Content-Transfer-Encoding: 8bit\r\n" +
                 "\r\n" +
                 "hello world\r\n" +
                 "--xxxxxxxxxxxxxxxxxxxxxxxx--\r\n", out.toString(Consts.ASCII.name()));

http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/5a44282c/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
----------------------------------------------------------------------
diff --git a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
index 6ee3f39..fc5b543 100644
--- a/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
+++ b/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
@@ -78,19 +78,16 @@ public class TestMultipartForm {
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field1\"\r\n" +
             "Content-Type: text/plain; charset=ISO-8859-1\r\n" +
-            "Content-Transfer-Encoding: 8bit\r\n" +
             "\r\n" +
             "this stuff\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field2\"\r\n" +
             "Content-Type: text/plain; charset=UTF-8\r\n" +
-            "Content-Transfer-Encoding: 8bit\r\n" +
             "\r\n" +
             "that stuff\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field3\"\r\n" +
             "Content-Type: text/plain; charset=ISO-8859-1\r\n" +
-            "Content-Transfer-Encoding: 8bit\r\n" +
             "\r\n" +
             "all kind of stuff\r\n" +
             "--foo--\r\n";
@@ -118,13 +115,11 @@ public class TestMultipartForm {
                 "--foo\r\n" +
                         "Content-Disposition: form-data; name=\"field1\"\r\n" +
                         "Content-Type: text/plain; charset=ISO-8859-1\r\n" +
-                        "Content-Transfer-Encoding: 8bit\r\n" +
                         "\r\n" +
                         "this stuff\r\n" +
                         "--foo\r\n" +
                         "Content-Disposition: form-data; name=\"field2\"\r\n" +
                         "Content-Type: stuff/plain; param=value\r\n" +
-                        "Content-Transfer-Encoding: 8bit\r\n" +
                         "\r\n" +
                         "that stuff\r\n" +
                         "--foo--\r\n";
@@ -162,14 +157,12 @@ public class TestMultipartForm {
             "Content-Disposition: form-data; name=\"field1\"; " +
                 "filename=\"" + tmpfile.getName() + "\"\r\n" +
             "Content-Type: application/octet-stream\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field2\"; " +
                 "filename=\"file.tmp\"\r\n" +
             "Content-Type: application/octet-stream\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo--\r\n";
@@ -210,21 +203,18 @@ public class TestMultipartForm {
             "Content-Disposition: form-data; name=\"field1\"; " +
                 "filename=\"" + tmpfile.getName() + "\"\r\n" +
             "Content-Type: application/octet-stream\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field2\"; " +
                 "filename=\"test-file\"\r\n" +
             "Content-Type: text/plain; charset=US-ASCII\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field3\"; " +
                 "filename=\"file.tmp\"\r\n" +
             "Content-Type: application/octet-stream\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo--\r\n";
@@ -265,21 +255,18 @@ public class TestMultipartForm {
             "Content-Disposition: form-data; name=\"field1\u0414\"; " +
                 "filename=\"" + tmpfile.getName() + "\"\r\n" +
             "Content-Type: application/octet-stream\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field2\"; " +
                 "filename=\"test-file\"\r\n" +
             "Content-Type: text/plain; charset=US-ASCII\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field3\"; " +
                 "filename=\"file.tmp\"\r\n" +
             "Content-Type: application/octet-stream\r\n" +
-            "Content-Transfer-Encoding: binary\r\n" +
             "\r\n" +
             "some random whatever\r\n" +
             "--foo--\r\n";
@@ -379,14 +366,12 @@ public class TestMultipartForm {
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field1\"\r\n" +
             "Content-Type: text/plain; charset=ISO-8859-1\r\n" +
-            "Content-Transfer-Encoding: 8bit\r\n" +
             "\r\n").getBytes(Consts.ASCII));
         out2.write(s1.getBytes(Consts.ISO_8859_1));
         out2.write(("\r\n" +
             "--foo\r\n" +
             "Content-Disposition: form-data; name=\"field2\"\r\n" +
             "Content-Type: text/plain; charset=KOI8-R\r\n" +
-            "Content-Transfer-Encoding: 8bit\r\n" +
             "\r\n").getBytes(Consts.ASCII));
         out2.write(s2.getBytes(Charset.forName("KOI8-R")));
         out2.write(("\r\n" +


Mime
View raw message