- From: Jean-Guilhem Rouel via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 04 Sep 2009 15:49:50 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util In directory hutz:/tmp/cvs-serv4610/src/org/w3c/unicorn/util Modified Files: ClientHttpRequest.java Log Message: Fixed MimeType issue with file upload (guessContentFromName() couldn't find the mimetype of a .css file) Also fixed command line client Index: ClientHttpRequest.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/util/ClientHttpRequest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ClientHttpRequest.java 3 Sep 2009 16:43:21 -0000 1.2 +++ ClientHttpRequest.java 4 Sep 2009 15:49:48 -0000 1.3 @@ -1,7 +1,6 @@ package org.w3c.unicorn.util; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -13,6 +12,8 @@ import java.util.Map; import java.util.Random; +import javax.activation.MimeType; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -300,7 +301,7 @@ * @throws IOException */ public void setParameter(final String sName, final String sFileName, - final InputStream aInputStream) throws IOException { + final InputStream aInputStream, final MimeType mimeType) throws IOException { ClientHttpRequest.logger .trace("setParameter(String, String, InputStream)"); if (ClientHttpRequest.logger.isDebugEnabled()) { @@ -315,32 +316,21 @@ this.write(sFileName); this.write('"'); this.newline(); +// String sType = URLConnection.guessContentTypeFromName(sFileName); +// if (sType == null) { +// sType = URLConnection.guessContentTypeFromStream(aInputStream); +// if (sType == null) { +// sType = "application/octet-stream"; +// } +// } this.write("Content-Type: "); - String sType = URLConnection.guessContentTypeFromName(sFileName); - if (sType == null) { - sType = "application/octet-stream"; - } - this.writeln(sType); + this.writeln(mimeType.toString()); this.newline(); ClientHttpRequest.pipe(aInputStream, this.aOutputStream); this.newline(); } /** - * adds a file parameter to the request - * - * @param sName - * parameter name - * @param aFile - * the file to upload - * @throws IOException - */ - public void setParameter(final String sName, final File aFile) - throws IOException { - this.setParameter(sName, aFile.getPath(), new FileInputStream(aFile)); - } - - /** * adds a parameter to the request; if the parameter is a File, the file is * uploaded, otherwise the string value of the parameter is passed in the * request
Received on Friday, 4 September 2009 15:50:00 UTC