@Override
public void write(OutputStream output, ByteArraySessionOutputBuffer buffer) throws IOException {
buffer.reset();
final InputStream payload = writePayload(buffer);
final long contentLength = buffer.contentLength();
this.warcHeaders.updateHeader(new WarcHeader(WarcHeader.Name.CONTENT_LENGTH, Long.toString(contentLength)));
Util.toOutputStream(BasicLineFormatter.formatProtocolVersion(WarcRecord.PROTOCOL_VERSION, null), output);
output.write(ByteArraySessionOutputBuffer.CRLF);
writeHeaders(this.warcHeaders, output);
output.write(ByteArraySessionOutputBuffer.CRLF);
ByteStreams.copy(payload, output);
output.write(ByteArraySessionOutputBuffer.CRLFCRLF);
}
java类org.apache.http.message.BasicLineFormatter的实例源码
AbstractWarcRecord.java 文件源码
项目:BUbiNG
阅读 31
收藏 0
点赞 0
评论 0
AbstractMessageWriter.java 文件源码
项目:lams
阅读 34
收藏 0
点赞 0
评论 0
/**
* Creates an instance of AbstractMessageWriter.
*
* @param buffer the session output buffer.
* @param formatter the line formatter.
* @param params HTTP parameters.
*/
public AbstractMessageWriter(final SessionOutputBuffer buffer,
final LineFormatter formatter,
final HttpParams params) {
super();
if (buffer == null) {
throw new IllegalArgumentException("Session input buffer may not be null");
}
this.sessionBuffer = buffer;
this.lineBuf = new CharArrayBuffer(128);
this.lineFormatter = (formatter != null) ?
formatter : BasicLineFormatter.DEFAULT;
}
AbstractWarcRecord.java 文件源码
项目:BUbiNG
阅读 30
收藏 0
点赞 0
评论 0
protected static void writeHeaders(final HeaderGroup headers, final OutputStream output) throws IOException {
for (final HeaderIterator it = headers.iterator(); it.hasNext();) {
final org.apache.http.Header header = it.nextHeader();
Util.toOutputStream(BasicLineFormatter.formatHeader(header, null), output);
output.write(ByteArraySessionOutputBuffer.CRLF);
}
}
ResponsePrinter.java 文件源码
项目:Bastion
阅读 31
收藏 0
点赞 0
评论 0
private void writeHeaders(Writer writer, BasicLineFormatter formatter) {
response.getHeaders().forEach(apiHeader -> {
try {
writer.append(BasicLineFormatter.formatHeader(new BasicHeader(apiHeader.getName(), apiHeader.getValue()), formatter)).append("\r\n");
} catch (IOException exception) {
throw new IllegalStateException(exception);
}
});
}
HttpRequestPrinter.java 文件源码
项目:Bastion
阅读 32
收藏 0
点赞 0
评论 0
private void writeHeadSection(Writer writer) throws IOException {
RequestExecutor executor = new RequestExecutor(request, BastionFactory.getDefaultBastionFactory().getConfiguration());
URL url = new URL(executor.getResolvedUrl());
BasicLineFormatter formatter = new BasicLineFormatter();
writeRequestLine(url, writer, formatter);
writeHeaders(url, executor.getHeaders(), writer, formatter);
writer.append("\r\n");
}
HttpRequestPrinter.java 文件源码
项目:Bastion
阅读 31
收藏 0
点赞 0
评论 0
private void writeHeaders(URL url, Collection<ApiHeader> headers, Writer writer, BasicLineFormatter formatter) throws IOException {
writer.append(BasicLineFormatter.formatHeader(new BasicHeader("Host", url.getHost()), formatter)).append("\r\n");
headers.forEach(apiHeader -> {
try {
writer.append(BasicLineFormatter.formatHeader(new BasicHeader(apiHeader.getName(), apiHeader.getValue()), formatter)).append("\r\n");
} catch (IOException exception) {
throw new IllegalStateException(exception);
}
});
}
ResponsePrinter.java 文件源码
项目:Bastion
阅读 26
收藏 0
点赞 0
评论 0
private void writeHeadSection(Writer writer) throws IOException {
BasicLineFormatter formatter = new BasicLineFormatter();
writeStatusLine(writer, formatter);
writeHeaders(writer, formatter);
writer.append("\r\n");
}
ResponsePrinter.java 文件源码
项目:Bastion
阅读 28
收藏 0
点赞 0
评论 0
private void writeStatusLine(Writer writer, BasicLineFormatter formatter) throws IOException {
String statusLine = BasicLineFormatter.formatStatusLine(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1),
response.getStatusCode(), response.getStatusText()), formatter);
writer.append(statusLine).append("\r\n");
}
HttpRequestPrinter.java 文件源码
项目:Bastion
阅读 35
收藏 0
点赞 0
评论 0
private void writeRequestLine(URL url, Writer writer, BasicLineFormatter formatter) throws IOException {
BasicRequestLine requestLine = new BasicRequestLine(request.method().getValue(), url.getFile(), new ProtocolVersion("HTTP", 1, 1));
writer.append(BasicLineFormatter.formatRequestLine(requestLine, formatter)).append("\r\n");
}