HttpResponse (Java SE 11 & JDK 11 [ad-hoc build]) (original) (raw)


public interface HttpResponse
An HTTP response.
An HttpResponse is not created directly, but rather returned as a result of sending an HttpRequest. An HttpResponse is made available when the response status code and headers have been received, and typically after the response body has also been completely received. Whether or not the HttpResponse is made available before the response body has been completely received depends on the BodyHandler provided when sending the HttpRequest.
This class provides methods for accessing the response status code, headers, the response body, and the HttpRequest corresponding to this response.
The following is an example of retrieving a response as a String:

   HttpResponse<String> response = client  
     .send(request, BodyHandlers.ofString());  

The class BodyHandlers provides implementations of many common response handlers. Alternatively, a custom BodyHandler implementation can be used.
Since:
11

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2018, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
DRAFT 11-internal+0-adhoc.chhegar.open