In order to strees what I am looking for:
I'd like to retrieve an HttpResponse representation that, if inserted in a
(properly setup) TCP/IP payload sent to another listening host (also using
HttpClient), would be successfully decoded by a HttpClient process waiting
on the execute for the response.
- A sends to B which sends to one of the hosts in set C (A->B->Cx)
- one of the hosts in set C replies to B which replies to A (Cx->B->A)
I have the control of A and B.
I implemented the solution using for B a simple (round robin) load balancer
written in node.js and an HttpClient java process for A.
The reason why I need the described feature is for implementing also B with
HttpClient, preferrably with no HttpCore components (which would be possible
since I am relying on an enterprise service bus that may send the raw output
of my B module as response to the A module).
Best,
Federico
andrefe wrote:
>
> Hi,
>
> Thank you for your response. I tried a "brutal approach" like the one you
> were suggesting: basically I've appended the following information within
> a stringbuffer for an HTML page:
> - Status line
>
> stringBuffer.append(httpResponse.getStatusLine()).append("\n");
>
> - iterated output of getAllHeaders():
>
> Header headers[] = httpResponse.getAllHeaders();
> for (Header header : headers) {
> stringBuffer.append(header.getName()).append(":
> ").append(header.getValue()).append("\n");
> }
> stringBuffer.append("\n");
>
> - entity body content, parsed from a byte array response handler that I've
> implemented
>
> String resp = new
> String(responseHandler.handleResponse(httpResponse),"UTF-8");
> stringBuffer.append(resp).append("\n");
>
>
> Still, the given output of while fetching an HTML web page (i.e.
> google.com) is different from the telnet output. A couple of headers (i.e.
> the content-length) are missing like some escaping sequences in the body.
>
> Federico
>
>
>
> Stephen J. Butler wrote:
>>
>> On Thu, Jul 12, 2012 at 12:51 PM, andrefe <[email protected]>
>> wrote:
>>> Using HttpClient 4.2, I was wondering why the capability of retrieving
>>> the
>>> raw byte content that is parsed in a HTTP response is not supported: am
>>> I
>>> missing something?
>>>
>>> In other words, is not possible to obtain the very same output of a GET
>>> request performed via telnet relying only on HttpClient methods?
>>
>> You're talking about not just the body, but all the headers? Getting
>> the byte[] of the response body is pretty easy
>> (response.getEntity().getContent() returns an InputStream). Don't know
>> about all the socket traffic.
>>
>> You can log the traffic easily, for debugging purposes, if that's what
>> you're after.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>>
>
--
View this message in context:
http://old.nabble.com/HttpResponse-raw-data-tp34152297p34152787.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]