cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Wang" <jeff.w...@originate.com>
Subject RE: WebClient - Content-Type Override?
Date Sun, 31 Jul 2011 21:17:12 GMT
We're trying to use Amazon's query string authentication.  We can set Content-Type to "", or
heck, to any other string.  It's just that the server uses the content type as part of its
signature calculation.  So when we generate the signature, we expected to set it with some
content type (tried it with either "" or an actual type, it doesn't matter.) If it gets overridden,
like what happens with webClient.get(), then the signatures will be wrong and auth will get
rejected.  The actual header has no meaning in a GET, but we do need to control what it is
so that the signatures match.

Jeff


-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Sent: Sun 7/31/2011 11:00 AM
To: users@cxf.apache.org
Subject: Re: WebClient - Content-Type Override?
 
Hi,

Does the server expect Content-Type being set even in case of GET requests ?

Cheers, Sergey
On 28/07/11 22:45, Jeff Wang wrote:
> Looking through the code, it seems that if the body is null (which has
> to be the case considering it's a get, then the content type is
> overwritten with wildcards.
> Using client.invoke("GET",""); solved the problem for me.
>
> Jeff
>
> -----Original Message-----
> From: Jeff Wang [mailto:jeff.wang@originate.com]
> Sent: Wednesday, July 27, 2011 5:29 PM
> To: users@cxf.apache.org
> Subject: WebClient - Content-Type Override?
>
> I'm trying to act as a proxy to a third party webservice, and need to
> transform a REST request.  One issue that I have is that the
> Content-Type header seems to get overridden no matter what I do.  The
> code is actually very simple (context is an @Context MessageContext
> variable):
>
> 		WebClient client = WebClient.create(url)
> 			.header("real-header-removed",
> "auth-string-removed")			
> //			.header("Content-Type",
> context.getHttpHeaders().getMediaType().toString());
> 			.type(context.getHttpHeaders().getMediaType());
>
> 		Response resp = client.get();
> 		return (InputStream)resp.getEntity();
>
> Neither the .header nor the .type worked.  The tcpmon output of the
> request is:
> Content-Type: */*
> real-header-removed: auth-string-removed
> Accept: application/xml
> User-Agent: Apache CXF 2.3.5
> Cache-Control: no-cache
> Pragma: no-cache
>
> How do I avoid the content Type override (or rather, why is it
> happening?)
> Btw, while looking for answers, I found my CXF server side answers
> relatively easily either via google or the archive.  But client
> questions seems to be rather rare, and mostly on the SOAP calls.  Are
> most people using other packages?
>
> thanks
> Jeff



Mime
  • Unnamed multipart/mixed (inline, None, 0 bytes)
View raw message