Search in sources :

Example 11 with HttpExchange

use of org.eclipse.jetty.client.HttpExchange in project jetty.project by eclipse.

the class HttpChannelOverFCGI method content.

protected boolean content(ByteBuffer buffer, Callback callback) {
    idle.notIdle();
    HttpExchange exchange = getHttpExchange();
    if (exchange != null)
        return receiver.responseContent(exchange, buffer, callback);
    callback.succeeded();
    return false;
}
Also used : HttpExchange(org.eclipse.jetty.client.HttpExchange)

Example 12 with HttpExchange

use of org.eclipse.jetty.client.HttpExchange in project jetty.project by eclipse.

the class HttpChannelOverFCGI method responseBegin.

protected boolean responseBegin(int code, String reason) {
    idle.notIdle();
    HttpExchange exchange = getHttpExchange();
    if (exchange == null)
        return false;
    exchange.getResponse().version(version).status(code).reason(reason);
    return receiver.responseBegin(exchange);
}
Also used : HttpExchange(org.eclipse.jetty.client.HttpExchange)

Example 13 with HttpExchange

use of org.eclipse.jetty.client.HttpExchange in project jetty.project by eclipse.

the class HttpChannelOverFCGI method responseHeaders.

protected boolean responseHeaders() {
    idle.notIdle();
    HttpExchange exchange = getHttpExchange();
    return exchange != null && receiver.responseHeaders(exchange);
}
Also used : HttpExchange(org.eclipse.jetty.client.HttpExchange)

Example 14 with HttpExchange

use of org.eclipse.jetty.client.HttpExchange in project jetty.project by eclipse.

the class HttpReceiverOverHTTP2 method onReset.

@Override
public void onReset(Stream stream, ResetFrame frame) {
    HttpExchange exchange = getHttpExchange();
    if (exchange == null)
        return;
    ErrorCode error = ErrorCode.from(frame.getError());
    String reason = error == null ? "reset" : error.name().toLowerCase(Locale.ENGLISH);
    exchange.getRequest().abort(new IOException(reason));
}
Also used : HttpExchange(org.eclipse.jetty.client.HttpExchange) ErrorCode(org.eclipse.jetty.http2.ErrorCode) IOException(java.io.IOException)

Example 15 with HttpExchange

use of org.eclipse.jetty.client.HttpExchange in project jetty.project by eclipse.

the class HttpReceiverOverHTTP2 method onHeaders.

@Override
public void onHeaders(Stream stream, HeadersFrame frame) {
    HttpExchange exchange = getHttpExchange();
    if (exchange == null)
        return;
    HttpResponse response = exchange.getResponse();
    MetaData.Response metaData = (MetaData.Response) frame.getMetaData();
    response.version(metaData.getHttpVersion()).status(metaData.getStatus()).reason(metaData.getReason());
    if (responseBegin(exchange)) {
        HttpFields headers = metaData.getFields();
        for (HttpField header : headers) {
            if (!responseHeader(exchange, header))
                return;
        }
        if (responseHeaders(exchange)) {
            int status = metaData.getStatus();
            boolean informational = HttpStatus.isInformational(status) && status != HttpStatus.SWITCHING_PROTOCOLS_101;
            if (frame.isEndStream() || informational)
                responseSuccess(exchange);
        }
    }
}
Also used : Response(org.eclipse.jetty.client.api.Response) HttpResponse(org.eclipse.jetty.client.HttpResponse) MetaData(org.eclipse.jetty.http.MetaData) HttpField(org.eclipse.jetty.http.HttpField) HttpFields(org.eclipse.jetty.http.HttpFields) HttpExchange(org.eclipse.jetty.client.HttpExchange) HttpResponse(org.eclipse.jetty.client.HttpResponse)

Aggregations

HttpExchange (org.eclipse.jetty.client.HttpExchange)24 FutureResponseListener (org.eclipse.jetty.client.util.FutureResponseListener)7 Response (org.eclipse.jetty.client.api.Response)6 Test (org.junit.Test)6 IOException (java.io.IOException)4 ExecutionException (java.util.concurrent.ExecutionException)3 HttpResponse (org.eclipse.jetty.client.HttpResponse)3 HttpFields (org.eclipse.jetty.http.HttpFields)3 EOFException (java.io.EOFException)2 HttpRequest (org.eclipse.jetty.client.HttpRequest)2 HttpResponseException (org.eclipse.jetty.client.HttpResponseException)2 MetaData (org.eclipse.jetty.http.MetaData)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ByteBuffer (java.nio.ByteBuffer)1 TimeoutException (java.util.concurrent.TimeoutException)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1