Package jodd.http
Class HttpResponse
- java.lang.Object
-
- jodd.http.HttpBase<HttpResponse>
-
- jodd.http.HttpResponse
-
public class HttpResponse extends HttpBase<HttpResponse>
HTTP response.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jodd.http.HttpBase
HttpBase.Defaults
-
-
Field Summary
Fields Modifier and Type Field Description protected HttpRequesthttpRequestprotected intstatusCodeprotected java.lang.StringstatusPhrase-
Fields inherited from class jodd.http.HttpBase
body, capitalizeHeaderKeys, charset, form, formEncoding, HEADER_ACCEPT, HEADER_ACCEPT_ENCODING, HEADER_AUTHORIZATION, HEADER_CLOSE, HEADER_CONNECTION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LENGTH, HEADER_CONTENT_TYPE, HEADER_ETAG, HEADER_HOST, HEADER_KEEP_ALIVE, HEADER_USER_AGENT, headers, HTTP_1_0, HTTP_1_1, httpProgressListener, httpVersion, mediaType, multipart
-
-
Constructor Summary
Constructors Constructor Description HttpResponse()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidassignHttpRequest(HttpRequest httpRequest)BindsHttpRequestto this response.protected Bufferbuffer(boolean fullResponse)Creates responsebuffer.HttpResponseclose()Closes requests connection if it was open.Cookie[]cookies()Returns list of valid cookies sent from server.HttpRequestgetHttpRequest()ReturnsHttpRequestthat created this response.java.lang.Stringlocation()Parses the 'location' header and returns an absolute URL for the provided path.static HttpResponsereadFrom(java.io.InputStream in)Reads response input stream and returnsresponse.intstatusCode()Returns response status code.HttpResponsestatusCode(int statusCode)Sets response status code.java.lang.StringstatusPhrase()Returns response status phrase.HttpResponsestatusPhrase(java.lang.String statusPhrase)Sets response status phrase.HttpResponseunzip()Unzips GZip-ed body content, removes the content-encoding header and sets the new content-length value.-
Methods inherited from class jodd.http.HttpBase
_header, _headerRaw, _this, accept, accept, acceptEncoding, acceptEncoding, body, body, bodyBytes, bodyRaw, bodyText, bodyText, bodyText, bodyText, capitalizeHeaderKeys, capitalizeHeaderKeys, charset, charset, connectionKeepAlive, contentEncoding, contentLength, contentLength, contentType, contentType, contentType, form, form, form, form, formBuffer, formEncoding, formOverwrite, header, header, header, header, header, headerNames, headerOverwrite, headerRemove, headers, headersClear, httpVersion, httpVersion, initForm, isConnectionPersistent, isFormMultipart, mediaType, mediaType, populateHeaderAndBody, readBody, readHeaders, resolveFormEncoding, sendTo, toByteArray, tokenAuthentication, toString, toString, wrapFormValue
-
-
-
-
Field Detail
-
statusCode
protected int statusCode
-
statusPhrase
protected java.lang.String statusPhrase
-
httpRequest
protected HttpRequest httpRequest
-
-
Method Detail
-
statusCode
public int statusCode()
Returns response status code.
-
statusCode
public HttpResponse statusCode(int statusCode)
Sets response status code.
-
statusPhrase
public java.lang.String statusPhrase()
Returns response status phrase.
-
statusPhrase
public HttpResponse statusPhrase(java.lang.String statusPhrase)
Sets response status phrase.
-
location
public java.lang.String location()
Parses the 'location' header and returns an absolute URL for the provided path. Returnsnullif no location was specified or throwsHttpExceptionif it was impossible to assemble a valid URL.RFC 2616 still required an absolute URL, whereas RFC 9110 introduced the support for relative paths.
-
cookies
public Cookie[] cookies()
Returns list of valid cookies sent from server. If no cookie found, returns an empty array. Invalid cookies are ignored.- Overrides:
cookiesin classHttpBase<HttpResponse>
-
unzip
public HttpResponse unzip()
Unzips GZip-ed body content, removes the content-encoding header and sets the new content-length value.
-
buffer
protected Buffer buffer(boolean fullResponse)
Creates responsebuffer.- Specified by:
bufferin classHttpBase<HttpResponse>
-
readFrom
public static HttpResponse readFrom(java.io.InputStream in)
Reads response input stream and returnsresponse. Supports both streamed and chunked response.
-
assignHttpRequest
void assignHttpRequest(HttpRequest httpRequest)
BindsHttpRequestto this response.
-
getHttpRequest
public HttpRequest getHttpRequest()
ReturnsHttpRequestthat created this response.
-
close
public HttpResponse close()
Closes requests connection if it was open. Should be called when using keep-alive connections. Otherwise, connection will be already closed.
-
-