protected void init(final OutputStream outstream, int buffersize, final HttpParams params) { if (outstream == null) { throw new IllegalArgumentException("Input stream may not be null"); } if (buffersize <= 0) { throw new IllegalArgumentException("Buffer size may not be negative or zero"); } if (params == null) { throw new IllegalArgumentException("HTTP parameters may not be null"); } this.outstream = outstream; this.buffer = new ByteArrayBuffer(buffersize); this.charset = HttpProtocolParams.getHttpElementCharset(params); this.ascii = this.charset.equalsIgnoreCase(HTTP.US_ASCII) || this.charset.equalsIgnoreCase(HTTP.ASCII); this.metrics = new HttpTransportMetricsImpl(); }
protected void init(final InputStream instream, int buffersize, final HttpParams params) { if (instream == null) { throw new IllegalArgumentException("Input stream may not be null"); } if (buffersize <= 0) { throw new IllegalArgumentException("Buffer size may not be negative or zero"); } if (params == null) { throw new IllegalArgumentException("HTTP parameters may not be null"); } this.instream = instream; this.buffer = new byte[buffersize]; this.bufferpos = 0; this.bufferlen = 0; this.linebuffer = new ByteArrayBuffer(buffersize); this.charset = HttpProtocolParams.getHttpElementCharset(params); this.ascii = this.charset.equalsIgnoreCase(HTTP.US_ASCII) || this.charset.equalsIgnoreCase(HTTP.ASCII); this.maxLineLen = params.getIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, -1); this.metrics = new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 */ protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 * * @deprecated (4.3) no longer used. */ @Deprecated protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
/** * @since 4.1 * * @deprecated (4.3) no longer used. */ @Deprecated protected HttpTransportMetricsImpl createTransportMetrics() { return new HttpTransportMetricsImpl(); }
String s = "HTTP/1.1 200 OK\r\n" + "Content-Length: 100\r\n" + "Content-Type: text/plain\r\n" + "Server: some-server\r\n" + "\r\n"; SessionInputBufferImpl sessionInputBuffer = new SessionInputBufferImpl(new HttpTransportMetricsImpl(), 2048); sessionInputBuffer.bind(new ByteArrayInputStream(s.getBytes(Consts.ASCII))); DefaultHttpResponseParser responseParser = new DefaultHttpResponseParser(sessionInputBuffer); HttpResponse response = responseParser.parse(); System.out.println(response);
byte[] content = getContent(packet.getData()); if (content.length > 0) { InputStream byteIS = new ByteArrayInputStream(content); SessionInputBufferImpl contentBuf = new SessionInputBufferImpl(new HttpTransportMetricsImpl(), content.length); contentBuf.bind(byteIS); ChunkedInputStream chunkedIS = new ChunkedInputStream(contentBuf); GZIPInputStream gzipIS = new GZIPInputStream(chunkedIS); while (gzipIS.available() != 0) { byte[] buf = new byte[128]; gzipIS.read(buf); contentBuilder.append(new String(buf, "UTF-8")); } gzipIS.close(); String contentString = contentBuilder.toString(); }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ @Nonnull private static SessionOutputBufferImpl sessionOutputBufferFrom (final @Nonnull OutputStream os) { final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl(); final SessionOutputBufferImpl sob = new SessionOutputBufferImpl(metrics, 100); sob.bind(os); return sob; }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ @Nonnull private static SessionInputBufferImpl sessionInputBufferFrom (final @Nonnull InputStream is) { final HttpTransportMetricsImpl metrics = new HttpTransportMetricsImpl(); final SessionInputBufferImpl sib = new SessionInputBufferImpl(metrics, 100); sib.bind(is); return sib; }
protected void init(final OutputStream outstream, int buffersize, final HttpParams params) { if (outstream == null) { throw new IllegalArgumentException("Input stream may not be null"); } if (buffersize <= 0) { throw new IllegalArgumentException("Buffer size may not be negative or zero"); } if (params == null) { throw new IllegalArgumentException("HTTP parameters may not be null"); } this.outstream = outstream; this.buffer = new ByteArrayBuffer(buffersize); this.charset = HttpProtocolParams.getHttpElementCharset(params); this.ascii = this.charset.equalsIgnoreCase(HTTP.US_ASCII) || this.charset.equalsIgnoreCase(HTTP.ASCII); this.metrics = new HttpTransportMetricsImpl(); }
HttpEventCodec(Map<String, String> env, InputStream input, OutputStream output) { this.env = env; SessionInputBufferImpl sib = new SessionInputBufferImpl(new HttpTransportMetricsImpl(), 65535); sib.bind(Objects.requireNonNull(input)); this.sib = sib; SessionOutputBufferImpl sob = new SessionOutputBufferImpl(new HttpTransportMetricsImpl(), 65535); sob.bind(output); this.sob = sob; parser = new DefaultHttpRequestParserFactory(null, null).create(sib, MessageConstraints.custom().setMaxHeaderCount(65535).setMaxLineLength(65535).build()); }