hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1051664 - /httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
Date Tue, 21 Dec 2010 21:43:57 GMT
Author: sebb
Date: Tue Dec 21 21:43:56 2010
New Revision: 1051664

URL: http://svn.apache.org/viewvc?rev=1051664&view=rev
Log:
Remove unnecessary null checks for mimeType and TransferEncoding

Modified:
    httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java?rev=1051664&r1=1051663&r2=1051664&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
(original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
Tue Dec 21 21:43:56 2010
@@ -93,21 +93,17 @@ public class FormBodyPart {
     }
 
     protected void generateContentType(final ContentBody body) {
-        if (body.getMimeType() != null) {
-            StringBuilder buffer = new StringBuilder();
-            buffer.append(body.getMimeType());
-            if (body.getCharset() != null) {
-                buffer.append("; charset=");
-                buffer.append(body.getCharset());
-            }
-            addField(MIME.CONTENT_TYPE, buffer.toString());
+        StringBuilder buffer = new StringBuilder();
+        buffer.append(body.getMimeType()); // MimeType cannot be null
+        if (body.getCharset() != null) { // charset may legitimately be null
+            buffer.append("; charset=");
+            buffer.append(body.getCharset());
         }
+        addField(MIME.CONTENT_TYPE, buffer.toString());
     }
 
     protected void generateTransferEncoding(final ContentBody body) {
-        if (body.getTransferEncoding() != null) {
-            addField(MIME.CONTENT_TRANSFER_ENC, body.getTransferEncoding());
-        }
+        addField(MIME.CONTENT_TRANSFER_ENC, body.getTransferEncoding()); // TE cannot be
null
     }
 
 }



Mime
View raw message