cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <>
Subject [jira] [Commented] (CXF-5267) WebClient using POST with chunking enabled (the default) can't read 401 error response stream
Date Thu, 12 Sep 2013 08:58:51 GMT


Sergey Beryozkin commented on CXF-5267:

I meant try using CXF Async HTTP conduit (Dan built it around Apache HTTP client) - its primary
role is to support async calls (ex, JAX-RS 2.0 AsyncInvoker is implemented on top of it),
but it can be used to do the sync calls too, add


then set that WebClient property and retry please.

> WebClient using POST with chunking enabled (the default) can't read 401 error response
> ---------------------------------------------------------------------------------------------
>                 Key: CXF-5267
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.5.3, 2.7.5
>         Environment: Linux
>            Reporter: Jesse Pangburn
>            Priority: Minor
> If I use WebClient to POST a message to a server, then I can't read the 401 error response
stream.  If I use GET, then I can read the response stream just fine.  If I use a HTTPConduit
and disable chunking then I can read the response content just fine in all cases.
> Here's a short grid showing the tests I performed:
> ||GET/POST||chunking||return code||result||
> |GET|disabled|401|response message ok|
> |POST|disabled|401|response message ok|
> |POST|enabled (default)|401|response message BLANK!|
> |GET|enabled (default)|401|response message ok|
> |POST|enabled (default)|200|response message ok|
> Here's the code I'm using (requestStream and webClient are initialized above.  webClient
is a WebClient and requestStream is an InputStream.):
> {|borderStyle=solid}
> String requestMethod = "POST";
> InputStream responseStream = null;
> Response response = null;
> try{
> 	responseStream = webClient.invoke(requestMethod, requestStream, InputStream.class);
> } catch (Exception e){
> 	logger.log(Level.WARNING, "caught exception using webClient to call " + webClient.getCurrentURI().toString(),
> }finally{
> 	// always assign the Response object
> 	response = webClient.getResponse();
> 	// if the response entity is a LoadingByteArrayOutputStream, then we can still grab
that response content
> 	try{
> 		Object entity = response.getEntity();
> 		if (entity instanceof ByteArrayInputStream){
> 			ByteArrayInputStream bais = (ByteArrayInputStream)entity;
> 			// the stream needs to be reset before we can really use it
> 			bais.reset();
> 			responseStream = bais;
> 		}
> 	}catch (Exception e){
> 		// darn, failed to get that response entity
> 	    logger.log(Level.WARNING, "tried to get response message despite webClient exception,
but failed", e);
> 		// nothing else we can do, at least Cloverleaf will get the 500 response code and error
is in the log
> 	}
> }
> {code}
> In the failure case, when I try to read (not shown) from the response stream I get a
"-1" indicating the stream is empty.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:

View raw message