public class HttpRequest extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Boolean |
async |
protected Integer |
connectTimeout |
protected xyz.cofe.cbuffer.ContentBuffer |
contentBuffer |
protected long |
contentOffsetStart |
protected xyz.cofe.collection.Func1<Object,URLConnection> |
data |
protected boolean |
followRedirect |
protected HttpListenersHelper |
httpListenerHelper |
long |
id
Идентификатор объекта в пределах приложения
|
protected Lock |
lock |
protected long |
maxDownloadSize |
protected Integer |
readTimeout |
protected static AtomicLong |
sequenceID |
| Constructor and Description |
|---|
HttpRequest(HttpRequest source) |
HttpRequest(URL url) |
HttpRequest(URL url,
HttpClient httpClient) |
| Modifier and Type | Method and Description |
|---|---|
Closeable |
addListener(HttpListener listener) |
Closeable |
addListener(HttpListener listener,
boolean weakLink) |
void |
applyHeadersTo(URLConnection connection) |
HttpRequest |
clone() |
HttpResponse |
createResponse()
Создание объекта HttpResponse
|
protected void |
fireEvent(HttpEvent event) |
int |
getConnectTimeout() |
xyz.cofe.cbuffer.ContentBuffer |
getContentBuffer()
Указывает буффер для content-а
|
long |
getContentOffsetStart()
Указывает с какой позиции записывать в content buffer
|
xyz.cofe.collection.Func1<Object,URLConnection> |
getData() |
HttpClient |
getHttpClient() |
HttpHeaders |
getHttpHeaders() |
long |
getId()
Получение идентификатора
|
Set<HttpListener> |
getListeners() |
long |
getMaxDownloadSize()
Возвращает максимум загужаемых данных, по умолчанию без ограничения
|
String |
getMethod()
Возвращает HTTP метод, по умолчанию GET
|
int |
getReadTimeout() |
URL |
getUrl()
Указывает запрашиваемый адрес
|
String |
getUserAgent() |
boolean |
isAsync()
Указывает асинхронный режим
|
boolean |
isFollowRedirect()
Переходить по redirect
|
URLConnection |
openURLConnection()
Открытие соединение, с учетом настроек:
proxy, connectTimeout, readTimeout, httpHeaders, method |
protected void |
prepareRequiredHeaders(URLConnection connection)
Подготовка обязательных заголовков
|
protected void |
prepareUserAgent(URLConnection connection)
Указание user-agent
|
void |
removeListener(HttpListener listener) |
void |
setAsync(boolean async)
Указывает асинхронный режим
|
void |
setConnectTimeout(int connectTimeoutMS) |
void |
setContentBuffer(xyz.cofe.cbuffer.ContentBuffer contentBuffer)
Указывает буффер для content-а
|
void |
setContentOffsetStart(long contentOffsetStart)
Указывает с какой позиции записывать в content buffer
|
void |
setData(xyz.cofe.collection.Func1<Object,URLConnection> data) |
void |
setFollowRedirect(boolean followRedirect)
Переходить по redirect
|
void |
setHttpClient(HttpClient httpClient) |
void |
setHttpHeaders(HttpHeaders headers) |
void |
setMaxDownloadSize(long maxSize)
Устанавливает максимум загужаемых данных.
|
void |
setMethod(String method)
Указывает HTTP метод
|
void |
setReadTimeout(int readTimeoutMS) |
void |
setUrl(URL url)
Указывает запрашиваемый адрес
|
void |
setUserAgent(String userAgent) |
protected static final AtomicLong sequenceID
protected final Lock lock
public final long id
protected Integer connectTimeout
protected Integer readTimeout
protected final HttpListenersHelper httpListenerHelper
protected Boolean async
protected xyz.cofe.cbuffer.ContentBuffer contentBuffer
protected long contentOffsetStart
protected long maxDownloadSize
protected boolean followRedirect
protected xyz.cofe.collection.Func1<Object,URLConnection> data
public HttpRequest(URL url)
public HttpRequest(URL url, HttpClient httpClient)
public HttpRequest(HttpRequest source)
public HttpRequest clone()
public final long getId()
public URL getUrl()
public void setUrl(URL url)
url - запрашиваемый адресpublic String getMethod()
public void setMethod(String method)
method - HTTP методpublic HttpClient getHttpClient()
public void setHttpClient(HttpClient httpClient)
public HttpHeaders getHttpHeaders()
public void setHttpHeaders(HttpHeaders headers)
public void applyHeadersTo(URLConnection connection)
public String getUserAgent()
public void setUserAgent(String userAgent)
public int getConnectTimeout()
public void setConnectTimeout(int connectTimeoutMS)
public int getReadTimeout()
public void setReadTimeout(int readTimeoutMS)
public Set<HttpListener> getListeners()
public Closeable addListener(HttpListener listener)
public Closeable addListener(HttpListener listener, boolean weakLink)
public void removeListener(HttpListener listener)
protected void fireEvent(HttpEvent event)
public boolean isAsync()
public void setAsync(boolean async)
async - true - асинхронный; false - синхронныйpublic xyz.cofe.cbuffer.ContentBuffer getContentBuffer()
public void setContentBuffer(xyz.cofe.cbuffer.ContentBuffer contentBuffer)
contentBuffer - буфферpublic long getContentOffsetStart()
public void setContentOffsetStart(long contentOffsetStart)
contentOffsetStart - позицияpublic long getMaxDownloadSize()
public void setMaxDownloadSize(long maxSize)
maxSize - макс загружаемых данных, maxSize < 0 - без ограниченийpublic boolean isFollowRedirect()
public void setFollowRedirect(boolean followRedirect)
followRedirect - true - переход по redirectpublic xyz.cofe.collection.Func1<Object,URLConnection> getData()
public void setData(xyz.cofe.collection.Func1<Object,URLConnection> data)
protected void prepareUserAgent(URLConnection connection)
connection - Коннектprotected void prepareRequiredHeaders(URLConnection connection)
connection - Открытое соединениеprepareUserAgent(java.net.URLConnection)public URLConnection openURLConnection() throws IOException
IOException - не может открыть соединениеpublic HttpResponse createResponse()
HttpResponseCopyright © 2017. All rights reserved.