没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
package org.apache.commons.httpclient.server;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import org.apache.commons.httpclient.ChunkedInputStream;
import org.apache.commons.httpclient.ContentLengthInputStream;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HeaderElement;
import org.apache.commons.httpclient.HeaderGroup;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.StatusLine;
/**
* A generic HTTP response.
*
* @author Christian Kohlschuetter
* @author Oleg Kalnichevski
*/
public class SimpleResponse {
public static final String DEFAULT_CONTENT_CHARSET = "ISO-8859-1";
private HttpVersion ver = HttpVersion.HTTP_1_1;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.Iterator;
import org.apache.commons.httpclient.ChunkedInputStream;
import org.apache.commons.httpclient.ContentLengthInputStream;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HeaderElement;
import org.apache.commons.httpclient.HeaderGroup;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.StatusLine;
/**
* A generic HTTP response.
*
* @author Christian Kohlschuetter
* @author Oleg Kalnichevski
*/
public class SimpleResponse {
public static final String DEFAULT_CONTENT_CHARSET = "ISO-8859-1";
private HttpVersion ver = HttpVersion.HTTP_1_1;
private int statuscode = HttpStatus.SC_OK;
private String phrase = HttpStatus.getStatusText(HttpStatus.SC_OK);
private HeaderGroup headers = new HeaderGroup();
private InputStream entity = null;
public SimpleResponse() {
super();
}
public SimpleResponse(
final StatusLine statusline,
final Header[] headers,
final InputStream content)
throws IOException {
super();
if (statusline == null) {
throw new IllegalArgumentException("Status line may not be null");
}
setStatusLine(HttpVersion.parse(statusline.getHttpVersion()),
statusline.getStatusCode(), statusline.getReasonPhrase());
setHeaders(headers);
if (content != null) {
InputStream in = content;
Header contentLength = this.headers.getFirstHeader("Content-Length");
Header transferEncoding = this.headers.getFirstHeader("Transfer-Encoding");
if (transferEncoding != null) {
if (transferEncoding.getValue().indexOf("chunked") != -1) {
in = new ChunkedInputStream(in);
}
private String phrase = HttpStatus.getStatusText(HttpStatus.SC_OK);
private HeaderGroup headers = new HeaderGroup();
private InputStream entity = null;
public SimpleResponse() {
super();
}
public SimpleResponse(
final StatusLine statusline,
final Header[] headers,
final InputStream content)
throws IOException {
super();
if (statusline == null) {
throw new IllegalArgumentException("Status line may not be null");
}
setStatusLine(HttpVersion.parse(statusline.getHttpVersion()),
statusline.getStatusCode(), statusline.getReasonPhrase());
setHeaders(headers);
if (content != null) {
InputStream in = content;
Header contentLength = this.headers.getFirstHeader("Content-Length");
Header transferEncoding = this.headers.getFirstHeader("Transfer-Encoding");
if (transferEncoding != null) {
if (transferEncoding.getValue().indexOf("chunked") != -1) {
in = new ChunkedInputStream(in);
}
剩余8页未读,继续阅读
资源评论
lzw78266283
- 粉丝: 1
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功