Class LowLevelHttpRequest (1.43.0)

public abstract class LowLevelHttpRequest

Low-level HTTP request.

This allows providing a different implementation of the HTTP request that is more compatible with the Java environment used.

Implementation has no fields and therefore thread-safe, but sub-classes are not necessarily thread-safe.

Inheritance

java.lang.Object > LowLevelHttpRequest

Constructors

LowLevelHttpRequest()

public LowLevelHttpRequest()

Methods

addHeader(String name, String value)

public abstract void addHeader(String name, String value)

Adds a header to the HTTP request.

Note that multiple headers of the same name need to be supported, in which case #addHeader will be called for each instance of the header.

Parameters
NameDescription
nameString

header name

valueString

header value

Exceptions
TypeDescription
IOException

execute()

public abstract LowLevelHttpResponse execute()

Executes the request and returns a low-level HTTP response object.

Returns
TypeDescription
LowLevelHttpResponse
Exceptions
TypeDescription
IOException

getContentEncoding()

public final String getContentEncoding()

Returns the content encoding (for example "gzip") or null for none.

Returns
TypeDescription
String

getContentLength()

public final long getContentLength()

Returns the content length or less than zero if not known.

Returns
TypeDescription
long

getContentType()

public final String getContentType()

Returns the content type or null for none.

Returns
TypeDescription
String

getStreamingContent()

public final StreamingContent getStreamingContent()

Returns the streaming content or null for no content.

Returns
TypeDescription
StreamingContent

setContentEncoding(String contentEncoding)

public final void setContentEncoding(String contentEncoding)

Sets the content encoding (for example "gzip") or null for none.

Parameter
NameDescription
contentEncodingString
Exceptions
TypeDescription
IOException

I/O exception

setContentLength(long contentLength)

public final void setContentLength(long contentLength)

Sets the content length or less than zero if not known.

Default value is -1.

Parameter
NameDescription
contentLengthlong
Exceptions
TypeDescription
IOException

I/O exception

setContentType(String contentType)

public final void setContentType(String contentType)

Sets the content type or null for none.

Parameter
NameDescription
contentTypeString
Exceptions
TypeDescription
IOException

I/O exception

setStreamingContent(StreamingContent streamingContent)

public final void setStreamingContent(StreamingContent streamingContent)

Sets the streaming content or null for no content.

Parameter
NameDescription
streamingContentStreamingContent
Exceptions
TypeDescription
IOException

I/O exception

setTimeout(int connectTimeout, int readTimeout)

public void setTimeout(int connectTimeout, int readTimeout)

Sets the connection and read timeouts.

Default implementation does nothing, but subclasses should normally override.

Parameters
NameDescription
connectTimeoutint

timeout in milliseconds to establish a connection or 0 for an infinite timeout

readTimeoutint

Timeout in milliseconds to read data from an established connection or 0 for an infinite timeout

Exceptions
TypeDescription
IOException

I/O exception

setWriteTimeout(int writeTimeout)

public void setWriteTimeout(int writeTimeout)

Sets the write timeout for POST/PUT requests.

Default implementation does nothing, but subclasses should normally override.

Parameter
NameDescription
writeTimeoutint

timeout in milliseconds to establish a connection or 0 for an infinite timeout

Exceptions
TypeDescription
IOException

I/O exception