Search in sources :

Example 31 with Http2Header

use of com.webpieces.http2parser.api.dto.lib.Http2Header in project webpieces by deanhiller.

the class Requests method createResponse.

public static Http2Response createResponse(int streamId) {
    List<Http2Header> headers = new ArrayList<>();
    headers.add(new Http2Header(Http2HeaderName.STATUS, StatusCode.HTTP_200_OK.getCodeString()));
    headers.add(new Http2Header(Http2HeaderName.SERVER, "me"));
    Http2Response response = new Http2Response(headers);
    response.setEndOfStream(false);
    response.setStreamId(streamId);
    return response;
}
Also used : Http2Response(com.webpieces.hpack.api.dto.Http2Response) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) ArrayList(java.util.ArrayList)

Example 32 with Http2Header

use of com.webpieces.http2parser.api.dto.lib.Http2Header in project webpieces by deanhiller.

the class Requests method createEosResponse.

public static Http2Response createEosResponse(int streamId) {
    List<Http2Header> headers = new ArrayList<>();
    headers.add(new Http2Header(Http2HeaderName.STATUS, StatusCode.HTTP_200_OK.getCodeString()));
    headers.add(new Http2Header(Http2HeaderName.SERVER, "me"));
    Http2Response response = new Http2Response(headers);
    response.setEndOfStream(true);
    response.setStreamId(streamId);
    return response;
}
Also used : Http2Response(com.webpieces.hpack.api.dto.Http2Response) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) ArrayList(java.util.ArrayList)

Example 33 with Http2Header

use of com.webpieces.http2parser.api.dto.lib.Http2Header in project webpieces by deanhiller.

the class Requests method createRequest.

static Http2Request createRequest(boolean eos) {
    List<Http2Header> headers = new ArrayList<>();
    headers.add(new Http2Header(Http2HeaderName.METHOD, "GET"));
    headers.add(new Http2Header(Http2HeaderName.AUTHORITY, "somehost.com"));
    headers.add(new Http2Header(Http2HeaderName.PATH, "/"));
    headers.add(new Http2Header(Http2HeaderName.SCHEME, "http"));
    headers.add(new Http2Header(Http2HeaderName.HOST, "somehost.com"));
    headers.add(new Http2Header(Http2HeaderName.ACCEPT, "*/*"));
    headers.add(new Http2Header(Http2HeaderName.ACCEPT_ENCODING, "gzip, deflate"));
    headers.add(new Http2Header(Http2HeaderName.USER_AGENT, "webpieces/1.15.0"));
    Http2Request request = new Http2Request(headers);
    request.setEndOfStream(eos);
    return request;
}
Also used : Http2Request(com.webpieces.hpack.api.dto.Http2Request) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) ArrayList(java.util.ArrayList)

Example 34 with Http2Header

use of com.webpieces.http2parser.api.dto.lib.Http2Header in project webpieces by deanhiller.

the class HeaderDecoding method decodeImpl.

private List<Http2Header> decodeImpl(UnmarshalStateImpl state, DataWrapper data, int streamId, Consumer<Http2Header> knownHeaders) throws IOException {
    List<Http2Header> headers = new ArrayList<>();
    byte[] bytes = data.createByteArray();
    ByteArrayInputStream in = new ByteArrayInputStream(bytes);
    Decoder decoder = state.getDecoder();
    //TODO(dhiller): make this an async syncrhonized block instead so threads can keep running!!!
    synchronized (decoder) {
        decoder.decode(in, (n, v, s) -> addToHeaders(headers, knownHeaders, n, v, s, state.getLogId(), streamId));
        decoder.endHeaderBlock();
    }
    if (data.getReadableSize() > 0 && headers.size() == 0)
        throw new ConnectionException(CancelReasonCode.COMPRESSION_ERROR, state.getLogId(), streamId, "Header data came in, but no headers came out");
    return headers;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header) ArrayList(java.util.ArrayList) Decoder(com.twitter.hpack.Decoder) ConnectionException(com.webpieces.http2parser.api.dto.error.ConnectionException)

Example 35 with Http2Header

use of com.webpieces.http2parser.api.dto.lib.Http2Header in project webpieces by deanhiller.

the class LoginFilter method addCacheHeaders.

private Object addCacheHeaders(Object response) {
    Http2Headers resp = (Http2Headers) response;
    //http://stackoverflow.com/questions/49547/how-to-control-web-page-caching-across-all-browsers
    //This forces the browser back button to re-request the page as it would never have the page
    //and is good to use to hide banking information type pages
    //resp.addHeader(new Header(KnownHeaderName.CACHE_CONTROL, "no-store")); 
    resp.addHeader(new Http2Header(Http2HeaderName.CACHE_CONTROL, "no-cache, no-store, must-revalidate"));
    resp.addHeader(new Http2Header(Http2HeaderName.PRAGMA, "no-cache"));
    resp.addHeader(new Http2Header(Http2HeaderName.EXPIRES, "0"));
    return resp;
}
Also used : Http2Headers(com.webpieces.hpack.api.dto.Http2Headers) Http2Header(com.webpieces.http2parser.api.dto.lib.Http2Header)

Aggregations

Http2Header (com.webpieces.http2parser.api.dto.lib.Http2Header)36 ArrayList (java.util.ArrayList)16 Http2Response (com.webpieces.hpack.api.dto.Http2Response)13 Http2Request (com.webpieces.hpack.api.dto.Http2Request)6 Http2HeaderName (com.webpieces.http2parser.api.dto.lib.Http2HeaderName)6 Http2Push (com.webpieces.hpack.api.dto.Http2Push)5 StreamWriter (com.webpieces.http2engine.api.StreamWriter)4 Http2Frame (com.webpieces.http2parser.api.dto.lib.Http2Frame)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Header (org.webpieces.httpparser.api.common.Header)4 Logger (org.webpieces.util.logging.Logger)4 LoggerFactory (org.webpieces.util.logging.LoggerFactory)4 List (java.util.List)3 BufferPool (org.webpieces.data.api.BufferPool)3 Encoder (com.twitter.hpack.Encoder)2 Http2Headers (com.webpieces.hpack.api.dto.Http2Headers)2 Http2Trailers (com.webpieces.hpack.api.dto.Http2Trailers)2 HeaderEncoding (com.webpieces.hpack.impl.HeaderEncoding)2 PushPromiseListener (com.webpieces.http2engine.api.PushPromiseListener)2 PushStreamHandle (com.webpieces.http2engine.api.PushStreamHandle)2