Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 292E6D392 for ; Mon, 5 Nov 2012 19:29:05 +0000 (UTC) Received: (qmail 29725 invoked by uid 500); 5 Nov 2012 19:29:04 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 29667 invoked by uid 500); 5 Nov 2012 19:29:04 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 29650 invoked by uid 99); 5 Nov 2012 19:29:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2012 19:29:04 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of brice.dutheil@gmail.com designates 209.85.214.41 as permitted sender) Received: from [209.85.214.41] (HELO mail-bk0-f41.google.com) (209.85.214.41) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Nov 2012 19:28:48 +0000 Received: by mail-bk0-f41.google.com with SMTP id jm1so2356420bkc.0 for ; Mon, 05 Nov 2012 11:28:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=n2tzhiu5B5SGWwD/GDF/ESLQevrtXcXZhgB0fFrIxMg=; b=DoPig2bdz9uI+h0thryAxlD9qYSmMV6OQmgj2hkEGm5bcbnfbj1ePBrdlitsg5r3ig sExQK6rMrrHs9kbr7EZ34BrAlp5zv+x8898O54tGUXTUiYLpcEyI39GYQy4OAgr2LAdv qCD60PcDbKS4sQp0OFbgZBJGUu/G/7oTwpzBFKelA8rj5IPDeC6ox8TCKxO7D56+LyZc ITkr88N1lKb2rptCT0GJrLB8hVnElbjZNaioDSQRJU3GuWRkPAI2UrEbaH/FUixuEiIB Tp/ldNyzytJ77AaONhg/0fBJ8HeToep6eILo9BObR57xzmxVGV/csduR4hIP1hjI7IWd 89Ew== Received: by 10.205.121.7 with SMTP id ga7mr2554582bkc.30.1352143706869; Mon, 05 Nov 2012 11:28:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.204.230.202 with HTTP; Mon, 5 Nov 2012 11:27:46 -0800 (PST) From: Brice Dutheil Date: Mon, 5 Nov 2012 20:27:46 +0100 Message-ID: Subject: Multipart values are not trimed To: users@cxf.apache.org Content-Type: multipart/alternative; boundary=000e0ce03bfa55502c04cdc47d20 X-Virus-Checked: Checked by ClamAV on apache.org --000e0ce03bfa55502c04cdc47d20 Content-Type: text/plain; charset=UTF-8 Hi, I'm crafting a resource that should accept multipart POST request. Here's the method : ================================================ @POST @Produces({MediaType.APPLICATION_JSON}) @Consumes(MediaType.MULTIPART_FORM_DATA) public MetaData archive(@FormParam("title") String title, @FormParam("revision") String revision, @Multipart("archive") TemporaryBinaryFile temporaryBinaryFile) { ================================================ Also I tried with @Multipart instead of @FormParam ================================================ @POST @Produces({MediaType.APPLICATION_JSON}) @Consumes(MediaType.MULTIPART_FORM_DATA) public DocumentMetaData archive(@Multipart(value = "title", required = false) @FormParam("title") String title, @Multipart(value = "revision", required = false) String revision, @Multipart("archive") TemporaryBinaryFile temporaryBinaryFile) { ================================================ And here is the raw request : ================================================ Address: http://localhost:8080/api/v1.0/document/archive Encoding: ISO-8859-1 Http-Method: POST Content-Type: multipart/form-data;boundary=partie Headers: {Accept=[*/*], accept-charset=[ISO-8859-1,utf-8;q=0.7,*;q=0.3], accept-encoding=[gzip,deflate,sdch], Content-Length=[301], content-type=[multipart/form-data;boundary=partie]} Payload: --partie Content-Disposition: form-data; name="title" Content-ID: title the.title --partie Content-Disposition: form-data; name="revision" Content-ID: revision some.revision --partie Content-Disposition: form-data; name="archive"; filename="file.txt" Content-Type: text/plain I've got a woman, way over town... --partie ================================================ However the title and revision values are incorrect because they are ended by a new line char '\n'. Hence these parameters are not validated by my validator (which is using Message.getContent), I don't think this is a normal behavior, but I might be wrong, maybe about the specs, or my request. Note that I had to add the Content-ID when using the Multipart annotation. Maybe there is something I should do ? I have a workaround for that, I've made an interceptor whose role is to trim strings. But I find it rather inelegant to do that. Or am I missing something ? Cheers -- Brice --000e0ce03bfa55502c04cdc47d20--