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 9E94B983F for ; Wed, 30 Nov 2011 19:54:48 +0000 (UTC) Received: (qmail 23856 invoked by uid 500); 30 Nov 2011 19:54:48 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 23800 invoked by uid 500); 30 Nov 2011 19:54:48 -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 23792 invoked by uid 99); 30 Nov 2011 19:54:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 19:54:48 +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 (athena.apache.org: domain of bimargulies@gmail.com designates 209.85.161.41 as permitted sender) Received: from [209.85.161.41] (HELO mail-fx0-f41.google.com) (209.85.161.41) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Nov 2011 19:54:41 +0000 Received: by faaa26 with SMTP id a26so1085962faa.0 for ; Wed, 30 Nov 2011 11:54:20 -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=yYH+gKFKy4SsmIT2pbZMfZzLaKJdqatN1ccMBoivw7A=; b=MLb1/xFmwnN6V2+uP1yU5VMwCyRf0NtK5wgVsA+9sYwMz4Ft9290iki390kCCwnMU/ WOKY4A4S+LK4ono0iiILy3efP0waq1M08RfA5ktQo6cKf0HS/8R1RGgWdx0O8iPMi2J3 yTM2QrKR8+G68aKrrOVYrgyIAs4H0MDRhnqOc= MIME-Version: 1.0 Received: by 10.180.4.67 with SMTP id i3mr2822398wii.1.1322682859811; Wed, 30 Nov 2011 11:54:19 -0800 (PST) Received: by 10.180.105.195 with HTTP; Wed, 30 Nov 2011 11:54:19 -0800 (PST) In-Reply-To: References: Date: Wed, 30 Nov 2011 14:54:19 -0500 Message-ID: Subject: Re: Failing to set an Origin header with a WebClient From: Benson Margulies To: CXF Dev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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.transpor= t.http.Servlet3ContinuationProvider@4ac5c32e, null, null, null, org.apache.cxf.message.Message.IN_INTERCEPTORS=3D[org.apache.cxf.transport.= 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 w= rote: > 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:" + PORT; > =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 Origi= n, 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.getStatusCode(= ), r.getStatus());