本文整理了Java中com.github.kevinsawicki.http.HttpRequest.getConnection()
方法的一些代码示例,展示了HttpRequest.getConnection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getConnection()
方法的具体详情如下:
包路径:com.github.kevinsawicki.http.HttpRequest
类名称:HttpRequest
方法名:getConnection
[英]Get underlying connection
[中]获取基础连接
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Set connect timeout on connection to given value
*
* @param timeout
* @return this request
*/
public HttpRequest connectTimeout(final int timeout) {
getConnection().setConnectTimeout(timeout);
return this;
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Set connect timeout on connection to given value
*
* @param timeout
* @return this request
*/
public HttpRequest connectTimeout(final int timeout) {
getConnection().setConnectTimeout(timeout);
return this;
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Set the 'Content-Length' request header to the given value
*
* @param contentLength
* @return this request
*/
public HttpRequest contentLength(final int contentLength) {
getConnection().setFixedLengthStreamingMode(contentLength);
return this;
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Get the {@link URL} of this request's connection
*
* @return request URL
*/
public URL url() {
return getConnection().getURL();
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Set read timeout on connection to given value
*
* @param timeout
* @return this request
*/
public HttpRequest readTimeout(final int timeout) {
getConnection().setReadTimeout(timeout);
return this;
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Set header name to given value
*
* @param name
* @param value
* @return this request
*/
public HttpRequest header(final String name, final String value) {
getConnection().setRequestProperty(name, value);
return this;
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Set whether or not the underlying connection should follow redirects in
* the response.
*
* @param followRedirects - true fo follow redirects, false to not.
* @return this request
*/
public HttpRequest followRedirects(final boolean followRedirects) {
getConnection().setInstanceFollowRedirects(followRedirects);
return this;
}
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Get the {@link URL} of this request's connection
*
* @return request URL
*/
public URL url() {
return getConnection().getURL();
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Set whether or not the underlying connection should follow redirects in
* the response.
*
* @param followRedirects - true fo follow redirects, false to not.
* @return this request
*/
public HttpRequest followRedirects(final boolean followRedirects) {
getConnection().setInstanceFollowRedirects(followRedirects);
return this;
}
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Disconnect the connection
*
* @return this request
*/
public HttpRequest disconnect() {
getConnection().disconnect();
return this;
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Set value of {@link HttpURLConnection#setUseCaches(boolean)}
*
* @param useCaches
* @return this request
*/
public HttpRequest useCaches(final boolean useCaches) {
getConnection().setUseCaches(useCaches);
return this;
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Set the 'Content-Length' request header to the given value
*
* @param contentLength
* @return this request
*/
public HttpRequest contentLength(final int contentLength) {
getConnection().setFixedLengthStreamingMode(contentLength);
return this;
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Set header name to given value
*
* @param name
* @param value
* @return this request
*/
public HttpRequest header(final String name, final String value) {
getConnection().setRequestProperty(name, value);
return this;
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Get a response header
*
* @param name
* @return response header
* @throws HttpRequestException
*/
public String header(final String name) throws HttpRequestException {
closeOutputQuietly();
return getConnection().getHeaderField(name);
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Set the 'If-Modified-Since' request header to the given value
*
* @param ifModifiedSince
* @return this request
*/
public HttpRequest ifModifiedSince(final long ifModifiedSince) {
getConnection().setIfModifiedSince(ifModifiedSince);
return this;
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Get all the response headers
*
* @return map of response header names to their value(s)
* @throws HttpRequestException
*/
public Map<String, List<String>> headers() throws HttpRequestException {
closeOutputQuietly();
return getConnection().getHeaderFields();
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Set chunked streaming mode to the given size
*
* @param size
* @return this request
*/
public HttpRequest chunk(final int size) {
getConnection().setChunkedStreamingMode(size);
return this;
}
代码示例来源:origin: com.github.kevinsawicki/http-request
/**
* Get the HTTP method of this request
*
* @return method
*/
public String method() {
return getConnection().getRequestMethod();
}
代码示例来源:origin: tcking/GiraffePlayer2
/**
* Set the 'If-Modified-Since' request header to the given value
*
* @param ifModifiedSince
* @return this request
*/
public HttpRequest ifModifiedSince(final long ifModifiedSince) {
getConnection().setIfModifiedSince(ifModifiedSince);
return this;
}
代码示例来源:origin: com.restfuse/com.eclipsesource.restfuse
public ResponseImpl( HttpRequest request ) {
body = request.body();
contentType = request.contentType();
headers = request.headers();
code = request.code();
url = request.getConnection().getURL().toString();
request.disconnect();
}
内容来源于网络,如有侵权,请联系作者删除!