@Override public boolean startRequest(HttpMethod method, String methodString, ByteBuffer uri, HttpVersion version) { _method=methodString; _uri=BufferUtil.toUTF8String(uri); _version=version; return false; }
@Override public String getPayloadAsUTF8() { if (data == null) { return null; } return BufferUtil.toUTF8String(data); } }
@Override public boolean startRequest(HttpMethod method, String methodString, ByteBuffer uri, HttpVersion version) { _method=methodString; _uri=BufferUtil.toUTF8String(uri); _version=version; return false; }
public String getPayloadAsUTF8() { if (data == null) { return null; } return BufferUtil.toUTF8String(data); }
public String getPayloadAsUTF8() { if (data == null) { return null; } return BufferUtil.toUTF8String(data); }
@Override public boolean startRequest(HttpMethod method, String methodString, ByteBuffer uri, HttpVersion version) { _method=methodString; _uri=BufferUtil.toUTF8String(uri); _version=version; return false; }
public String getPayloadAsUTF8() { if (data == null) { return null; } return BufferUtil.toUTF8String(data); }
public String getPayloadAsUTF8() { return BufferUtil.toUTF8String(getPayload()); }
public ByteBuffer getResponses(ByteBuffer request) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("Request (Buffer): {}",BufferUtil.toUTF8String(request)); } return _connector.getResponses(request); }
public ByteBuffer getResponses(ByteBuffer requestsBuffer,long idleFor,TimeUnit units) throws Exception { if (LOG.isDebugEnabled()) { LOG.debug("Requests (Buffer): {}",BufferUtil.toUTF8String(requestsBuffer)); } return _connector.getResponses(requestsBuffer, idleFor, units); }
/** Get a single response using a parser to search for the end of the message. * @param requestBuffer The request to send * @param time The time to wait * @param unit The units of the wait * @return ByteBuffer containing response or null. * @throws Exception If there is a problem */ public ByteBuffer getResponse(ByteBuffer requestBuffer, long time,TimeUnit unit) throws Exception { boolean head = BufferUtil.toString(requestBuffer).toLowerCase().startsWith("head "); if (LOG.isDebugEnabled()) LOG.debug("requests {}", BufferUtil.toUTF8String(requestBuffer)); LocalEndPoint endp = executeRequest(requestBuffer); return endp.waitForResponse(head,time,unit); }
/** Get a single response using a parser to search for the end of the message. * @param rawRequest The request to send * @param time The time to wait * @param unit The units of the wait * @return ByteBuffer containing response or null. * @throws Exception If there is a problem */ public String getResponse(String rawRequest,long time,TimeUnit unit) throws Exception { boolean head = rawRequest.toLowerCase().startsWith("head "); ByteBuffer requestsBuffer = BufferUtil.toBuffer(rawRequest, StandardCharsets.ISO_8859_1); if (LOG.isDebugEnabled()) LOG.debug("request {}", BufferUtil.toUTF8String(requestsBuffer)); LocalEndPoint endp = executeRequest(requestsBuffer); return BufferUtil.toString(endp.waitForResponse(head,time,unit), StandardCharsets.ISO_8859_1); }
/** Get a single response using a parser to search for the end of the message. * @param requestBuffer The request to send * @param head True if the response is for a head request * @param time The time to wait * @param unit The units of the wait * @return ByteBuffer containing response or null. * @throws Exception If there is a problem */ public ByteBuffer getResponse(ByteBuffer requestBuffer,boolean head, long time,TimeUnit unit) throws Exception { if (LOG.isDebugEnabled()) LOG.debug("requests {}", BufferUtil.toUTF8String(requestBuffer)); LocalEndPoint endp = executeRequest(requestBuffer); return endp.waitForResponse(head,time,unit); }
/** Sends requests and get's responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. * <p> * This methods waits until the connection is closed or * an idle period before returning the responses. * @param requestsBuffer the requests * @param idleFor The time the response stream must be idle for before returning * @param units The units of idleFor * @return the responses * @throws Exception if the requests fail */ public ByteBuffer getResponses(ByteBuffer requestsBuffer,long idleFor,TimeUnit units) throws Exception { LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer)); LocalEndPoint endp = executeRequest(requestsBuffer); endp.waitUntilClosedOrIdleFor(idleFor,units); ByteBuffer responses = endp.takeOutput(); endp.getConnection().close(); LOG.debug("responses {}", BufferUtil.toUTF8String(responses)); return responses; }
/** Sends requests and get's responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. * <p> * This methods waits until the connection is closed or * an idle period before returning the responses. * @param requestsBuffer the requests * @param idleFor The time the response stream must be idle for before returning * @param units The units of idleFor * @return the responses * @throws Exception if the requests fail */ public ByteBuffer getResponses(ByteBuffer requestsBuffer,long idleFor,TimeUnit units) throws Exception { LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer)); LocalEndPoint endp = executeRequest(requestsBuffer); endp.waitUntilClosedOrIdleFor(idleFor,units); ByteBuffer responses = endp.takeOutput(); endp.getConnection().close(); LOG.debug("responses {}", BufferUtil.toUTF8String(responses)); return responses; }
/** Sends requests and get's responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. * <p> * This methods waits until the connection is closed or * an idle period before returning the responses. * @param requestsBuffer the requests * @param idleFor The time the response stream must be idle for before returning * @param units The units of idleFor * @return the responses * @throws Exception if the requests fail * @deprecated Use {@link #getResponse(ByteBuffer, boolean, long, TimeUnit)} */ @Deprecated public ByteBuffer getResponses(ByteBuffer requestsBuffer,long idleFor,TimeUnit units) throws Exception { if (LOG.isDebugEnabled()) LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer)); LocalEndPoint endp = executeRequest(requestsBuffer); endp.waitUntilClosedOrIdleFor(idleFor,units); ByteBuffer responses = endp.takeOutput(); if (endp.isOutputShutdown()) endp.close(); if (LOG.isDebugEnabled()) LOG.debug("responses {}", BufferUtil.toUTF8String(responses)); return responses; }
/** Sends requests and get's responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. * <p> * This methods waits until the connection is closed or * an idle period before returning the responses. * @param requestsBuffer the requests * @param idleFor The time the response stream must be idle for before returning * @param units The units of idleFor * @return the responses * @throws Exception if the requests fail */ public ByteBuffer getResponses(ByteBuffer requestsBuffer,long idleFor,TimeUnit units) throws Exception { if (LOG.isDebugEnabled()) LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer)); LocalEndPoint endp = executeRequest(requestsBuffer); endp.waitUntilClosedOrIdleFor(idleFor,units); ByteBuffer responses = endp.takeOutput(); if (endp.isOutputShutdown()) endp.close(); if (LOG.isDebugEnabled()) LOG.debug("responses {}", BufferUtil.toUTF8String(responses)); return responses; }
/** Sends requests and get's responses based on thread activity. * Returns all the responses received once the thread activity has * returned to the level it was before the requests. * <p> * This methods waits until the connection is closed or * an idle period before returning the responses. * @param requestsBuffer the requests * @param idleFor The time the response stream must be idle for before returning * @param units The units of idleFor * @return the responses * @throws Exception if the requests fail */ public ByteBuffer getResponses(ByteBuffer requestsBuffer,long idleFor,TimeUnit units) throws Exception { if (LOG.isDebugEnabled()) LOG.debug("requests {}", BufferUtil.toUTF8String(requestsBuffer)); LocalEndPoint endp = executeRequest(requestsBuffer); endp.waitUntilClosedOrIdleFor(idleFor,units); ByteBuffer responses = endp.takeOutput(); if (endp.isOutputShutdown()) endp.close(); if (LOG.isDebugEnabled()) LOG.debug("responses {}", BufferUtil.toUTF8String(responses)); return responses; }
/** Get a single response using a parser to search for the end of the message. * @param rawRequest The request to send * @param head True if the response is for a head request * @param time The time to wait * @param unit The units of the wait * @return ByteBuffer containing response or null. * @throws Exception If there is a problem */ public String getResponse(String rawRequest, boolean head, long time,TimeUnit unit) throws Exception { ByteBuffer requestsBuffer = BufferUtil.toBuffer(rawRequest, StandardCharsets.ISO_8859_1); if (LOG.isDebugEnabled()) LOG.debug("request {}", BufferUtil.toUTF8String(requestsBuffer)); LocalEndPoint endp = executeRequest(requestsBuffer); return BufferUtil.toString(endp.waitForResponse(head,time,unit), StandardCharsets.ISO_8859_1); }
@Override public boolean startRequest(HttpMethod method, String methodString, ByteBuffer uri, HttpVersion httpVersion) { Connector connector = getConnector(); String scheme = connector.getConnectionFactory(SslConnectionFactory.class) != null ? "https" : "http"; headers.put(HTTPSPDYHeader.SCHEME.name(version), scheme); headers.put(HTTPSPDYHeader.METHOD.name(version), methodString); headers.put(HTTPSPDYHeader.URI.name(version), BufferUtil.toUTF8String(uri)); // TODO handle bad encodings headers.put(HTTPSPDYHeader.VERSION.name(version), httpVersion.asString()); return false; }