Upgraded HttpCore dependency to version 4.0-beta3; upgraded Mime4j dependency to version 0.5

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@705898 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2008-10-18 17:14:05 +00:00
parent 07aab6a52d
commit a2027f5d14
4 changed files with 72 additions and 10 deletions

View File

@ -32,6 +32,7 @@
package org.apache.http.entity.mime;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.descriptor.ContentDescriptor;
import org.apache.james.mime4j.field.Field;
import org.apache.james.mime4j.message.BodyPart;
@ -82,7 +83,7 @@ public class FormBodyPart extends BodyPart {
buffer.append(body.getFilename());
buffer.append("\"");
}
getHeader().addField(Field.parse(buffer.toString()));
addField(buffer.toString());
}
protected void generateContentType(final ContentDescriptor desc) {
@ -95,7 +96,7 @@ public class FormBodyPart extends BodyPart {
buffer.append("; charset=");
buffer.append(desc.getCharset());
}
getHeader().addField(Field.parse(buffer.toString()));
addField(buffer.toString());
}
}
@ -105,8 +106,17 @@ public class FormBodyPart extends BodyPart {
buffer.append(MIME.CONTENT_TRANSFER_ENC);
buffer.append(": ");
buffer.append(desc.getTransferEncoding());
getHeader().addField(Field.parse(buffer.toString()));
addField(buffer.toString());
}
}
private void addField(final String s) {
try {
getHeader().addField(Field.parse(s));
} catch (MimeException ex) {
// Should never happen
throw new UnexpectedMimeException(ex);
}
}
}

View File

@ -44,6 +44,7 @@ import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.content.ContentBody;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.apache.james.mime4j.MimeException;
import org.apache.james.mime4j.field.Field;
import org.apache.james.mime4j.message.Message;
@ -62,6 +63,7 @@ public class MultipartEntity implements HttpEntity {
"-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
.toCharArray();
private final Message message;
private final HttpMultipart multipart;
private final Header contentType;
@ -79,17 +81,16 @@ public class MultipartEntity implements HttpEntity {
generateContentType(boundary, charset));
this.dirty = true;
Message message = new Message();
this.message = new Message();
org.apache.james.mime4j.message.Header header =
new org.apache.james.mime4j.message.Header();
header.addField(
Field.parse("Content-Type: " + this.contentType.getValue()));
message.setHeader(header);
this.message.setHeader(header);
this.multipart.setParent(message);
if (mode == null) {
mode = HttpMultipartMode.STRICT;
}
this.multipart.setMode(mode);
addField("Content-Type: " + this.contentType.getValue());
}
public MultipartEntity(final HttpMultipartMode mode) {
@ -179,4 +180,13 @@ public class MultipartEntity implements HttpEntity {
this.multipart.writeTo(outstream);
}
private void addField(final String s) {
try {
this.message.getHeader().addField(Field.parse(s));
} catch (MimeException ex) {
// Should never happen
throw new UnexpectedMimeException(ex);
}
}
}

View File

@ -0,0 +1,43 @@
/*
* $HeadURL:$
* $Revision:$
* $Date:$
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.entity.mime;
import org.apache.james.mime4j.MimeException;
public class UnexpectedMimeException extends RuntimeException {
private static final long serialVersionUID = 1316818299528463579L;
public UnexpectedMimeException(MimeException ex) {
super(ex.getMessage(), ex);
}
}

View File

@ -70,11 +70,10 @@
</scm>
<properties>
<httpcore.version>4.0-beta2</httpcore.version>
<httpcore.version>4.0-beta3</httpcore.version>
<commons-logging.version>1.1.1</commons-logging.version>
<commons-codec.version>1.3</commons-codec.version>
<commons-io.version>1.2</commons-io.version>
<mime4j.version>0.4</mime4j.version>
<mime4j.version>0.5</mime4j.version>
<junit.version>3.8.2</junit.version>
</properties>