HiThe hint from Alex Declent, "The solution is to set the system property sun.net.http.allowRestrictedHeaders to true. ", should help here as well, I may update the CORS tests to use WebClient and see if it helps...
Cheers, Sergey On 01/12/11 16:13, Sergey Beryozkin wrote:
Hi Dan On 01/12/11 16:09, Daniel Kulp wrote:On Thursday, December 01, 2011 10:04:27 AM Sergey Beryozkin wrote:Hi Benson so HTTPUrlConnection drops 'Origin' ? It's unfortunate. It seems we'd need to look into some sort of integration with Apache Http Client at some time,Started working on that a long time ago: http://svn.apache.org/repos/asf/cxf/branches/async- client/rt/transports/http/src/main/java/org/apache/cxf/transport/http/async/ Just never had time to really finish it. :-(The reflection trick you proposed may get us past this particular issue :-)...Making it OSGI can be a concern, but may be, as far as CORS is concerned, it's mainly targeted at browser consumers, not sure though Actually, just wondering if it is possible to 'fix' HTTPUrlConnection to support arbitrary HTTP verbs... thanks, SergeyDanSergey 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=[http://localhost:9000], Accept=[text/plain], Content-Type=[*/*]} -------------------------------------- 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=[text/plain], Cache-Control=[no-cache], connection=[keep-alive], content-type=[*/*], Host=[localhost:9000], Pragma=[no-cache], User-Agent=[Apache CXF ${project.version}]} On Wed, Nov 30, 2011 at 2:54 PM, Benson Margulies<bimargul...@gmail.com>wrote: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={Accept=[text/plain], Cache-Control=[no-cache], connection=[keep-alive], content-type=[*/*], Host=[localhost:9000], Pragma=[no-cache], User-Agent=[Apache CXF ${project.version}]}, null, null, null, null, null, null, HTTP_CONTEXT_MATCH_STRATEGY=stem, org.apache.cxf.request.url=http://localhost:9000/simpleGet/HelloThere, null, null, null, null, org.apache.cxf.request.uri=/simpleGet/HelloThere, null, org.apache.cxf.resource.method=public java.lang.String org.apache.cxf.systest.jaxrs.cors.CorsServer.simpleGet(java.lang.Strin g), HTTP.REQUEST=(GET /simpleGet/HelloThere)@372285153 org.eclipse.jetty.server.Request@16309ee1, null, null, HTTP.CONFIG=org.eclipse.jetty.servlet.ServletHolder$Config@520ed128, Accept=text/plain, null, org.apache.cxf.message.Message.PATH_INFO=/simpleGet/HelloThere, null, null, null, null, null, null, null, null, org.apache.cxf.continuations.ContinuationProvider=org.apache.cxf.trans port.http.Servlet3ContinuationProvider@4ac5c32e, null, null, null, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transpo rt.https.CertConstraintsInterceptor@7d91275b], null, null, org.apache.cxf.message.Message.QUERY_STRING=null, HTTP.RESPONSE=HTTP/1.1 200 On Wed, Nov 30, 2011 at 2:47 PM, Benson Margulies<bimargul...@gmail.com>wrote: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. String origin = "http://localhost:" + PORT; WebClient wc = WebClient.create(origin + "/"); // Since our WebClient doesn't know from Origin, we need to do this ourselves. wc.header("Origin", origin); Response r = wc.replacePath("/simpleGet/HelloThere").accept("text/plain").get(); assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
-- Sergey Beryozkin Talend Community Coders http://coders.talend.com/ Blog: http://sberyozkin.blogspot.com