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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations