Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4EDB4200BD9 for ; Fri, 9 Dec 2016 17:32:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4D7E8160B1D; Fri, 9 Dec 2016 16:32:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 9588B160AFD for ; Fri, 9 Dec 2016 17:32:05 +0100 (CET) Received: (qmail 96193 invoked by uid 500); 9 Dec 2016 16:32:04 -0000 Mailing-List: contact dev-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list dev@cxf.apache.org Received: (qmail 96181 invoked by uid 99); 9 Dec 2016 16:32:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Dec 2016 16:32:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 03318C7986 for ; Fri, 9 Dec 2016 16:32:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.121 X-Spam-Level: X-Spam-Status: No, score=-0.121 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id xTR4qjxoe0A2 for ; Fri, 9 Dec 2016 16:32:03 +0000 (UTC) Received: from mail-wj0-f174.google.com (mail-wj0-f174.google.com [209.85.210.174]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 9468D5FDE9 for ; Fri, 9 Dec 2016 16:32:02 +0000 (UTC) Received: by mail-wj0-f174.google.com with SMTP id v7so18902775wjy.2 for ; Fri, 09 Dec 2016 08:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=5qhl1qU9CrhyzIqFcatKxSKdQ9SykAXMV/H7DBXVaPE=; b=WOAP9A+6peoylbNJI46xKvE2ya3iTtiCBSQ/TJsEWWf7N+jOJRlDXswqEiK+yuP4Mc 28dNh6cMm8p8F4fs3Cm49jw4Z2ga5xl2QuM/3PVu0OcADEMBI8QxPtkeZGhGrJHzAnQE Z9w9PRUpYop+QHt/UX0rres4fUPvivZvocEJpygi6vRlN1g0vyQ78jEZACGG3ABukNv/ mQs2Mkc5n6R52+vHTktOAEiqm42BStECljaVs9D8SOE/q26fAIS8+NY1dTiZkX2DEe4V oBSj9Z32Gori1nhyEl4aLfm3qwY1uqeKp/YKqaDSHDVk9OLfULiYjeNXIG65/oF2kDdm QC9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=5qhl1qU9CrhyzIqFcatKxSKdQ9SykAXMV/H7DBXVaPE=; b=fpX5icm2swzg8FkCE227qj3meIv3QOm0DpqP1FtQ3HMLLy2H2vlA9QUe0k6YNgSJXb Mo+X7eVWRNb2EnPeCNi6WwTPARzJIwVG4rYq62T56IkN/v+O/fyIynDLE8fzsIlciyik IGQO6Belbz+ErrSYxg4O17Q26dduNPdDvXDD1yEWmUV0Cir9T8pXGLOLmJVHuFesAClf q9uCDzZ7zeDZPoSRK3rq869w8vfQjCeLbV4ILstZ9INMWAKRMVdV53ngSGhPLnXdoiiq N5pjiJOnIjlp66ErWbBUCmcUXB5bTXQoATuRvfEH1ZSBGe7pCQXCEO2fI2hcbJ74lnbi Is4A== X-Gm-Message-State: AKaTC001ItG8zPf3hOzl6qkbiAggQE1sM0Nrx9d1TsPaEoxw8V4yDmBJOGaTPX7GbuRUZQ== X-Received: by 10.194.164.226 with SMTP id yt2mr80045645wjb.201.1481301121441; Fri, 09 Dec 2016 08:32:01 -0800 (PST) Received: from [10.36.226.98] ([80.169.137.53]) by smtp.googlemail.com with ESMTPSA id d184sm21408573wmd.8.2016.12.09.08.32.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Dec 2016 08:32:00 -0800 (PST) Subject: Re: MediaType matching question To: dev@cxf.apache.org References: <32DE5B4C-4388-4371-9E28-34D4F3E493DC@yahoo.de> <456020132.1100977.1481300226679@mail.yahoo.com> <2aa27848-59af-addf-cbcb-90f14a9f8833@gmail.com> From: Sergey Beryozkin Message-ID: <52d8be9a-8374-3915-0246-1b35a6f4e466@gmail.com> Date: Fri, 9 Dec 2016 16:32:00 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <2aa27848-59af-addf-cbcb-90f14a9f8833@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit archived-at: Fri, 09 Dec 2016 16:32:06 -0000 Actually I'm not sure I understand, you mention application/octet-stream, @Consumes below won't be matched, is application/json issue relevant ? application/json is expected to match application/json+x but not the other way around. Cheers, Sergey On 09/12/16 16:23, Sergey Beryozkin wrote: > Hi Mark, welcome, > > Do you expect a "*/*+json" match the application/octet-stream ? > And how is the method parameter accepting a multipart payload is typed, > as InputStream ? > > As a side note with WebClient you can use a more dedicated Attachment > code but on the server side, if you need to stay 100% compliant, then > yes, you;d need to read from InputStream and parse the payload manually > - CXF MultipartProvider will not touch it unless it is annotated with a > CXF specific annotation > > Cheers, Sergey > > On 09/12/16 16:17, Mark Struberg wrote: >> While debugging through this didn't get used as far as I remember. >> >> Maybe MultipartProvider uses an alternative path to detect the handlers? >> >> LieGrue, >> strub >> >> >> >> >>> On Friday, 9 December 2016, 17:15, Romain Manni-Bucau >>> wrote: >>>> Hey Mark, >>> >>> have a look >>> to >>> org.apache.cxf.jaxrs.provider.ProviderFactory.MessageBodyWriterComparator >>> >>> (and the reader companion) maybe. Got aligned in cxf "jaxrs 2" for >>> spec >>> alignment >>> >>> >>> Romain Manni-Bucau >>> @rmannibucau | Blog >>> | Old Blog >>> | Github >>> | >>> LinkedIn | JavaEE Factory >>> >>> >>> >>> 2016-12-09 17:10 GMT+01:00 Mark Struberg : >>> >>>> good evening! >>>> >>>> My first post to CXF, so I excuse if I ask something obvious ;) >>>> >>>> We have the following code over in Apache OpenWebBeans / Meecrowave: >>>> >>>> @Produces({ >>>> "application/json", "*/json", >>>> "*/*+json", "*/x-json", >>>> "*/javascript", "*/x-javascript" >>>> }) >>>> @Consumes({ >>>> "application/json", "*/json", >>>> "*/*+json", "*/x-json", >>>> "*/javascript", "*/x-javascript" >>>> }) >>>> public static class ConfiguredJsonbJaxrsProvider extends >>>> JsonbJaxrsProvider { >>>> >>>> I tried to use the CXF WebClient to send a multipart form with a file >>>> attachment. MediaType is application/octet-stream. >>>> Sadly I always triggered our Johnzon JSONB provider >>>> (johnzon.apache.org). >>>> >>>> The reason is that */json seems to match ANY other MediaType, >>>> regardless >>>> of the subtype. Is this intended? >>>> The code I found during debugging is the following in >>>> geronimo-jaxrs_2.0 >>>> MediaType: >>>> >>>> public boolean isCompatible(MediaType other) { >>>> return other != null && (type.equals(MEDIA_TYPE_WILDCARD) || >>>> other.type.equals(MEDIA_TYPE_WILDCARD) || >>>> (type.equalsIgnoreCase(other.type) && >>> (subtype.equals(MEDIA_TYPE_WILDCARD) >>>> || other.subtype.equals(MEDIA_TYPE_WILDCARD))) || >>>> (type.equalsIgnoreCase(other.type) && >>>> this.subtype.equalsIgnoreCase(other.subtype))); >>>> } >>>> >>>> >>>> I'm geronimo PMC myself so I can even fix it. But would need some >>> feedback >>>> how it should behave. >>>> https://svn.apache.org/repos/asf/geronimo/specs/trunk/ >>>> geronimo-jaxrs_2.0_spec/ >>>> >>>> I did a quick look at the RI and now I'm even more confused: >>>> >>>> public boolean isCompatible(MediaType other) { >>>> return other != null && // return false if other is null, >>> else >>>> (type.equals(MEDIA_TYPE_WILDCARD) || >>>> other.type.equals(MEDIA_TYPE_WILDCARD) || // both are wildcard >>>> types, or >>>> (type.equalsIgnoreCase(other.type) && >>>> (subtype.equals(MEDIA_TYPE_WILDCARD) >>>> || >>> other.subtype.equals(MEDIA_TYPE_WILDCARD))) >>>> || // same types, wildcard sub-types, or >>>> (type.equalsIgnoreCase(other.type) && >>>> this.subtype.equalsIgnoreCase(other.subtype))); // same types & >>> sub-types >>>> } >>>> >>>> It says "both are wildcard types" but the code is actually ONE of >>> them is >>>> a wildcard type, isn't? >>>> (type.equals(MEDIA_TYPE_WILDCARD) || >>> other.type.equals(MEDIA_TYPE_WILDCARD) >>>> || // both are wildcard types, or >>>> >>>> >>>> Any hints are highly welcome, my head is already hurting... >>>> >>>> What are the actual rules for matching MediaTypes? What does the spec >>>> define? >>>> >>>> txs and LieGrue, >>>> strub >>>> >>>> >>>> >>>> >>> > > -- Sergey Beryozkin Talend Community Coders http://coders.talend.com/