public boolean handlesPayloadType(final Request request) { return (request.getStringData() != null); }
} else if (request.getStringData() != null) { if (!request.getHeaders().containsKey("Content-Type")) { urlConnection.setRequestProperty("Content-Type", "text/html;" + bodyCharset); byte[] b = request.getStringData().getBytes(bodyCharset); urlConnection.setRequestProperty("Content-Length", String.valueOf(b.length)); urlConnection.getOutputStream().write(b);
@SuppressWarnings({"unchecked"}) public boolean generate(final FilterChainContext ctx, final Request request, final HttpRequestPacket requestPacket) throws IOException { String charset = request.getBodyEncoding(); if (charset == null) { charset = Charsets.ASCII_CHARSET.name(); } final byte[] data = request.getStringData().getBytes(charset); final MemoryManager mm = ctx.getMemoryManager(); final Buffer gBuffer = Buffers.wrap(mm, data); if (requestPacket.getContentLength() == -1) { requestPacket.setContentLengthLong(data.length); } final HttpContent content = requestPacket.httpContentBuilder() .content(gBuffer) .last(true) .build(); ctx.write(content, ((!requestPacket.isCommitted()) ? ctx.getTransportContext().getCompletionHandler() : null)); return true; }
@Override public String getStringData() { return delegate.getStringData(); }
public boolean handlesPayloadType(final Request request) { return (request.getStringData() != null); }
public boolean handlesPayloadType(final Request request) { return (request.getStringData() != null); }
public boolean handlesBodyType(final Request request) { return (request.getStringData() != null); }
public RequestImpl(Request prototype) { if (prototype != null) { this.method = prototype.getMethod(); this.uri = prototype.getUri(); this.address = prototype.getInetAddress(); this.localAddress = prototype.getLocalAddress(); this.headers = new FluentCaseInsensitiveStringsMap(prototype.getHeaders()); this.cookies = new ArrayList<>(prototype.getCookies()); this.byteData = prototype.getByteData(); this.compositeByteData = prototype.getCompositeByteData(); this.stringData = prototype.getStringData(); this.streamData = prototype.getStreamData(); this.bodyGenerator = prototype.getBodyGenerator(); this.formParams = prototype.getFormParams() == null ? null : new ArrayList<>(prototype.getFormParams()); this.parts = prototype.getParts() == null ? null : new ArrayList<>(prototype.getParts()); this.virtualHost = prototype.getVirtualHost(); this.length = prototype.getContentLength(); this.proxyServer = prototype.getProxyServer(); this.realm = prototype.getRealm(); this.file = prototype.getFile(); this.followRedirects = prototype.getFollowRedirect(); this.requestTimeout = prototype.getRequestTimeout(); this.rangeOffset = prototype.getRangeOffset(); this.charset = prototype.getBodyEncoding(); this.connectionPoolPartitioning = prototype.getConnectionPoolPartitioning(); this.nameResolver = prototype.getNameResolver(); } }
/** The body of the request, for debugging purposes. */ public String getBody() { return httpRequestBuilder.build().getStringData(); }
nettyBody = new NettyCompositeByteArrayBody(request.getCompositeByteData()); else if (request.getStringData() != null) nettyBody = new NettyByteBufferBody(StringUtils.charSequence2ByteBuffer(request.getStringData(), bodyCharset));
if (MiscUtils.isNonEmpty(request.getFormParams())) requestBuilder.setFormParams(request.getFormParams()); else if (request.getStringData() != null) requestBuilder.setBody(request.getStringData()); else if (request.getByteData() != null) requestBuilder.setBody(request.getByteData());
? ningRequest.getStringData() : new String(ningRequest.getByteData(), Charset.forName(charset));
} else if (request.getStringData() != null) { if (!request.getHeaders().containsKey("Content-Type")) { urlConnection.setRequestProperty("Content-Type", "text/html;" + bodyCharset); byte[] b = request.getStringData().getBytes(bodyCharset); urlConnection.setRequestProperty("Content-Length", String.valueOf(b.length)); urlConnection.getOutputStream().write(b);
@SuppressWarnings({"unchecked"}) public boolean generate(final FilterChainContext ctx, final Request request, final HttpRequestPacket requestPacket) throws IOException { String charset = request.getBodyEncoding(); if (charset == null) { charset = Charsets.ASCII_CHARSET.name(); } final byte[] data = request.getStringData().getBytes(charset); final MemoryManager mm = ctx.getMemoryManager(); final Buffer gBuffer = Buffers.wrap(mm, data); if (requestPacket.getContentLength() == -1) { requestPacket.setContentLengthLong(data.length); } final HttpContent content = requestPacket.httpContentBuilder() .content(gBuffer) .last(true) .build(); ctx.write(content, ((!requestPacket.isCommitted()) ? ctx.getTransportContext().getCompletionHandler() : null)); return true; }
@SuppressWarnings({"unchecked"}) public boolean generate(final FilterChainContext ctx, final Request request, final HttpRequestPacket requestPacket) throws IOException { String charset = request.getBodyEncoding(); if (charset == null) { charset = Charsets.ASCII_CHARSET.name(); } final byte[] data = request.getStringData().getBytes(charset); final MemoryManager mm = ctx.getMemoryManager(); final Buffer gBuffer = Buffers.wrap(mm, data); if (requestPacket.getContentLength() == -1) { requestPacket.setContentLengthLong(data.length); } final HttpContent content = requestPacket.httpContentBuilder() .content(gBuffer) .last(true) .build(); ctx.write(content, ((!requestPacket.isCommitted()) ? ctx.getTransportContext().getCompletionHandler() : null)); return true; }
@SuppressWarnings({"unchecked"}) public boolean doHandle(final FilterChainContext ctx, final Request request, final HttpRequestPacket requestPacket) throws IOException { String charset = request.getBodyEncoding(); if (charset == null) { charset = Charsets.ASCII_CHARSET.name(); } final byte[] data = request.getStringData().getBytes(charset); final MemoryManager mm = ctx.getMemoryManager(); final Buffer gBuffer = Buffers.wrap(mm, data); if (requestPacket.getContentLength() == -1) { if (!clientConfig.isCompressionEnabled()) { requestPacket.setContentLengthLong(data.length); } } final HttpContent content = requestPacket.httpContentBuilder().content(gBuffer).build(); content.setLast(true); ctx.write(content, ((!requestPacket.isCommitted()) ? ctx.getTransportContext().getCompletionHandler() : null)); return true; }
public RequestImpl(Request prototype) { if (prototype != null) { this.method = prototype.getMethod(); this.uri = prototype.getURI(); this.address = prototype.getInetAddress(); this.localAddress = prototype.getLocalAddress(); this.headers = new FluentCaseInsensitiveStringsMap(prototype.getHeaders()); this.cookies = new ArrayList<Cookie>(prototype.getCookies()); this.byteData = prototype.getByteData(); this.stringData = prototype.getStringData(); this.streamData = prototype.getStreamData(); this.bodyGenerator = prototype.getBodyGenerator(); this.formParams = prototype.getFormParams() == null ? null : new ArrayList<Param>(prototype.getFormParams()); this.parts = prototype.getParts() == null ? null : new ArrayList<Part>(prototype.getParts()); this.virtualHost = prototype.getVirtualHost(); this.length = prototype.getContentLength(); this.proxyServer = prototype.getProxyServer(); this.realm = prototype.getRealm(); this.file = prototype.getFile(); this.followRedirects = prototype.getFollowRedirect(); this.requestTimeout = prototype.getRequestTimeout(); this.rangeOffset = prototype.getRangeOffset(); this.charset = prototype.getBodyEncoding(); this.connectionPoolKeyStrategy = prototype.getConnectionPoolKeyStrategy(); } }
public RequestImpl(Request prototype) { if (prototype != null) { this.method = prototype.getMethod(); this.uri = prototype.getUri(); this.address = prototype.getInetAddress(); this.localAddress = prototype.getLocalAddress(); this.headers = new FluentCaseInsensitiveStringsMap(prototype.getHeaders()); this.cookies = new ArrayList<>(prototype.getCookies()); this.byteData = prototype.getByteData(); this.compositeByteData = prototype.getCompositeByteData(); this.stringData = prototype.getStringData(); this.streamData = prototype.getStreamData(); this.bodyGenerator = prototype.getBodyGenerator(); this.formParams = prototype.getFormParams() == null ? null : new ArrayList<>(prototype.getFormParams()); this.parts = prototype.getParts() == null ? null : new ArrayList<>(prototype.getParts()); this.virtualHost = prototype.getVirtualHost(); this.length = prototype.getContentLength(); this.proxyServer = prototype.getProxyServer(); this.realm = prototype.getRealm(); this.file = prototype.getFile(); this.followRedirects = prototype.getFollowRedirect(); this.requestTimeout = prototype.getRequestTimeout(); this.rangeOffset = prototype.getRangeOffset(); this.charset = prototype.getBodyEncoding(); this.connectionPoolPartitioning = prototype.getConnectionPoolPartitioning(); this.nameResolver = prototype.getNameResolver(); } }
public RequestImpl(Request prototype) { if (prototype != null) { this.method = prototype.getMethod(); this.uri = prototype.getUri(); this.address = prototype.getInetAddress(); this.localAddress = prototype.getLocalAddress(); this.headers = new FluentCaseInsensitiveStringsMap(prototype.getHeaders()); this.cookies = new ArrayList<>(prototype.getCookies()); this.byteData = prototype.getByteData(); this.compositeByteData = prototype.getCompositeByteData(); this.stringData = prototype.getStringData(); this.streamData = prototype.getStreamData(); this.bodyGenerator = prototype.getBodyGenerator(); this.formParams = prototype.getFormParams() == null ? null : new ArrayList<>(prototype.getFormParams()); this.parts = prototype.getParts() == null ? null : new ArrayList<>(prototype.getParts()); this.virtualHost = prototype.getVirtualHost(); this.length = prototype.getContentLength(); this.proxyServer = prototype.getProxyServer(); this.realm = prototype.getRealm(); this.file = prototype.getFile(); this.followRedirects = prototype.getFollowRedirect(); this.requestTimeout = prototype.getRequestTimeout(); this.rangeOffset = prototype.getRangeOffset(); this.charset = prototype.getBodyEncoding(); this.connectionPoolPartitioning = prototype.getConnectionPoolPartitioning(); this.nameResolver = prototype.getNameResolver(); } }
private NettyBody body(Request request, HttpMethod method) throws IOException { NettyBody nettyBody = null; if (method != HttpMethod.CONNECT) { Charset bodyCharset = request.getBodyEncoding() == null ? DEFAULT_CHARSET : Charset.forName(request.getBodyEncoding()); if (request.getByteData() != null) nettyBody = new NettyByteArrayBody(request.getByteData()); else if (request.getStringData() != null) nettyBody = new NettyByteArrayBody(request.getStringData().getBytes(bodyCharset)); else if (request.getStreamData() != null) nettyBody = new NettyInputStreamBody(request.getStreamData()); else if (isNonEmpty(request.getFormParams())) { String contentType = null; if (!request.getHeaders().containsKey(HttpHeaders.Names.CONTENT_TYPE)) contentType = HttpHeaders.Values.APPLICATION_X_WWW_FORM_URLENCODED; nettyBody = new NettyByteArrayBody(computeBodyFromParams(request.getFormParams(), bodyCharset), contentType); } else if (isNonEmpty(request.getParts())) nettyBody = new NettyMultipartBody(request.getParts(), request.getHeaders(), nettyConfig); else if (request.getFile() != null) nettyBody = new NettyFileBody(request.getFile(), nettyConfig); else if (request.getBodyGenerator() instanceof FileBodyGenerator) { FileBodyGenerator fileBodyGenerator = (FileBodyGenerator) request.getBodyGenerator(); nettyBody = new NettyFileBody(fileBodyGenerator.getFile(), fileBodyGenerator.getRegionSeek(), fileBodyGenerator.getRegionLength(), nettyConfig); } else if (request.getBodyGenerator() instanceof InputStreamBodyGenerator) nettyBody = new NettyInputStreamBody(InputStreamBodyGenerator.class.cast(request.getBodyGenerator()).getInputStream()); else if (request.getBodyGenerator() != null) nettyBody = new NettyBodyBody(request.getBodyGenerator().createBody(), nettyConfig); } return nettyBody; }