Author: tchemit Date: 2009-10-30 21:24:58 +0100 (Fri, 30 Oct 2009) New Revision: 618 Modified: trunk/src/main/java/org/nuiton/io/rest/RestSession.java Log: add more logs Modified: trunk/src/main/java/org/nuiton/io/rest/RestSession.java =================================================================== --- trunk/src/main/java/org/nuiton/io/rest/RestSession.java 2009-10-16 12:25:15 UTC (rev 617) +++ trunk/src/main/java/org/nuiton/io/rest/RestSession.java 2009-10-30 20:24:58 UTC (rev 618) @@ -48,11 +48,18 @@ /** * A REST session. - * + * * @author chemit * @since 1.0.3 */ public class RestSession { +// uncomment this to debug the request send by httpclient +// static { +// System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); +// System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); +// System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug"); +// System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug"); +// } protected HttpClient client; protected static final Log log = LogFactory.getLog(RestSession.class); @@ -219,6 +226,9 @@ continue; } paramParts.add(new StringPart(key, value)); + if (log.isDebugEnabled()) { + log.debug("add parameter [" + key + "]=" + value); + } } } @@ -226,12 +236,21 @@ for (Entry<String, File> entry : attachments.entrySet()) { String key = entry.getKey(); File file = entry.getValue(); - paramParts.add(new FilePart(key, file.getName(), file)); + if (log.isDebugEnabled()) { + log.debug("add attachment " + key + "=" + file); + } + paramParts.add(new FilePart(key, file.getName(), file, FilePart.DEFAULT_CONTENT_TYPE, configuration.getEncoding())); } + if (attachments.isEmpty()) { + log.warn("no attachment in a multi-part request!"); + } Part[] parts = paramParts.toArray(new Part[paramParts.size()]); MultipartRequestEntity entity = new MultipartRequestEntity(parts, gm.getParams()); + if (log.isDebugEnabled()) { + entity.writeRequest(System.out); + } gm.setRequestEntity(entity); // gm.addRequestHeader("content-type", "multipart/form-data"); gm.addRequestHeader("content-type", entity.getContentType());
participants (1)
-
tchemit@users.nuiton.org