Return-Path: X-Original-To: apmail-cxf-dev-archive@www.apache.org Delivered-To: apmail-cxf-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4F2BC789A for ; Thu, 1 Dec 2011 11:40:13 +0000 (UTC) Received: (qmail 69567 invoked by uid 500); 1 Dec 2011 11:40:13 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 69527 invoked by uid 500); 1 Dec 2011 11:40:13 -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 69519 invoked by uid 99); 1 Dec 2011 11:40:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 11:40:13 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of bimargulies@gmail.com designates 209.85.215.169 as permitted sender) Received: from [209.85.215.169] (HELO mail-ey0-f169.google.com) (209.85.215.169) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Dec 2011 11:40:06 +0000 Received: by eaah1 with SMTP id h1so2440456eaa.0 for ; Thu, 01 Dec 2011 03:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=tWhAdCubVObzjxnsdeEMXxgS95hGKj5/ECM/U+5qh3c=; b=g5Cqlo4F/nc4dm0vP7KKYhNI7qlkKy3HZq/l42c4RzBJxcSBbWWOVqYKaXSEB9H+qe jNkXN6dSLtl/5hvAbvQFbESz8DBdoHRQLR5jqAOfynEBHL6K89Sj2EJfuS+QYS5Emy9d jbisR+zSx6LMdm6vLrZ/c4jeKfCEOS/QjYaj0= MIME-Version: 1.0 Received: by 10.216.182.137 with SMTP id o9mr367917wem.5.1322739585918; Thu, 01 Dec 2011 03:39:45 -0800 (PST) Received: by 10.180.105.195 with HTTP; Thu, 1 Dec 2011 03:39:45 -0800 (PST) In-Reply-To: <4ED7512B.20508@gmail.com> References: <4ED7512B.20508@gmail.com> Date: Thu, 1 Dec 2011 06:39:45 -0500 Message-ID: Subject: Re: Failing to set an Origin header with a WebClient From: Benson Margulies To: dev@cxf.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Dec 1, 2011 at 5:04 AM, Sergey Beryozkin wro= te: > Hi Benson > so HTTPUrlConnection drops 'Origin' ? It's unfortunate. > It seems we'd need to look into some sort of integration with Apache Http Yea. a new, optional, transport? > Client at some time, > Sergey > > On 30/11/11 20:00, Benson Margulies wrote: >> >> Logging. The output logger on the web client shows Origin, but not the >> input logger on the JAX-RS endpoint it's talking to. >> >> INFO: Outbound Message >> --------------------------- >> ID: 1 >> Address: http://localhost:9000/simpleGet/HelloThere >> Http-Method: GET >> Content-Type: */* >> Headers: {Origin=3D[http://localhost:9000], Accept=3D[text/plain], >> Content-Type=3D[*/*]} >> -------------------------------------- >> Nov 30, 2011 2:58:48 PM org.apache.cxf.interceptor.LoggingInInterceptor >> INFO: Inbound Message >> ---------------------------- >> ID: 2 >> Address: http://localhost:9000/simpleGet/HelloThere >> Http-Method: GET >> Content-Type: */* >> Headers: {Accept=3D[text/plain], Cache-Control=3D[no-cache], >> connection=3D[keep-alive], content-type=3D[*/*], Host=3D[localhost:9000]= , >> Pragma=3D[no-cache], User-Agent=3D[Apache CXF ${project.version}]} >> >> On Wed, Nov 30, 2011 at 2:54 PM, Benson Margulies >> =C2=A0wrote: >>> >>> I dumped the exchange, and Origin isn't in there. I haven't turned on >>> the logging interceptors yet. >>> >>> [null, null, null, null, null, null, null, null, null, >>> org.apache.cxf.message.Message.PROTOCOL_HEADERS=3D{Accept=3D[text/plain= ], >>> Cache-Control=3D[no-cache], connection=3D[keep-alive], content-type=3D[= */*], >>> Host=3D[localhost:9000], Pragma=3D[no-cache], User-Agent=3D[Apache CXF >>> ${project.version}]}, null, null, null, null, null, null, >>> HTTP_CONTEXT_MATCH_STRATEGY=3Dstem, >>> org.apache.cxf.request.url=3Dhttp://localhost:9000/simpleGet/HelloThere= , >>> null, null, null, null, >>> org.apache.cxf.request.uri=3D/simpleGet/HelloThere, null, >>> org.apache.cxf.resource.method=3Dpublic java.lang.String >>> org.apache.cxf.systest.jaxrs.cors.CorsServer.simpleGet(java.lang.String= ), >>> HTTP.REQUEST=3D(GET /simpleGet/HelloThere)@372285153 >>> org.eclipse.jetty.server.Request@16309ee1, null, null, >>> HTTP.CONFIG=3Dorg.eclipse.jetty.servlet.ServletHolder$Config@520ed128, >>> Accept=3Dtext/plain, null, >>> org.apache.cxf.message.Message.PATH_INFO=3D/simpleGet/HelloThere, null, >>> null, null, null, null, null, null, null, >>> >>> org.apache.cxf.continuations.ContinuationProvider=3Dorg.apache.cxf.tran= sport.http.Servlet3ContinuationProvider@4ac5c32e, >>> null, null, null, >>> >>> org.apache.cxf.message.Message.IN_INTERCEPTORS=3D[org.apache.cxf.transp= ort.https.CertConstraintsInterceptor@7d91275b], >>> null, null, org.apache.cxf.message.Message.QUERY_STRING=3Dnull, >>> HTTP.RESPONSE=3DHTTP/1.1 200 >>> >>> On Wed, Nov 30, 2011 at 2:47 PM, Benson Margulies >>> =C2=A0wrote: >>>> >>>> I'm failing to set an Origin header with a WebClient. Here's the >>>> client side code, and the header does not make it to the other end. >>>> >>>> This makes it rather difficult to write tests for CORS. >>>> >>>> On the other hand, should WebClient have native support for the client >>>> side of CORS? That's complex and unpleasant in prospect. >>>> >>>> >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0String origin =3D "http://localhost:" + POR= T; >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0WebClient wc =3D WebClient.create(origin + = "/"); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0// Since our WebClient doesn't know from Or= igin, we need to do >>>> this ourselves. >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0wc.header("Origin", origin); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0Response r =3D >>>> wc.replacePath("/simpleGet/HelloThere").accept("text/plain").get(); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0assertEquals(Response.Status.OK.getStatusCo= de(), r.getStatus()); > > > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com