use of com.webpieces.http2.api.dto.lowlevel.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, String.valueOf(StatusCode.HTTP_200_OK.getCode())));
headers.add(new Http2Header(Http2HeaderName.SERVER, "me"));
Http2Response response = new Http2Response(headers);
response.setEndOfStream(true);
response.setStreamId(streamId);
return response;
}
use of com.webpieces.http2.api.dto.lowlevel.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;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class Requests method createBaseRequest.
public static Http2Request createBaseRequest(String method, String scheme, String path) {
Http2Request req = new Http2Request();
req.addHeader(new Http2Header(Http2HeaderName.AUTHORITY, "yourdomain.com"));
req.addHeader(new Http2Header(Http2HeaderName.SCHEME, scheme));
req.addHeader(new Http2Header(Http2HeaderName.METHOD, method));
req.addHeader(new Http2Header(Http2HeaderName.PATH, path));
return req;
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class Requests method createJsonRequest.
public static FullRequest createJsonRequest(String method, String url, String json) {
Http2Request req = createBaseRequest(method, "https", url);
DataWrapper body = gen.wrapByteArray(json.getBytes());
req.addHeader(new Http2Header(Http2HeaderName.CONTENT_LENGTH, body.getReadableSize() + ""));
return new FullRequest(req, body, null);
}
use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Header in project webpieces by deanhiller.
the class ResponseWrapperHttp2 method createCookieRequestHeader.
/**
* Example request cookie from chrome
* Cookie: webSession=1-gzvc03bKRP2YYvWySwgENREwFSg=:__ST=3a2fda5dad7547d3b15b1f61bd3d12f5; webFlash=1:_message=Invalid+values+below&user.address.zipCode=Text+instead+of+number&__secureToken=3a2fda5dad7547d3b15b1f61bd3d12f5&user.firstName=Dean+Hiller; webErrors=1:user.address.zipCode=Could+not+convert+value
* @return
*/
public Http2Header createCookieRequestHeader() {
List<Http2Header> headers = getResponse().getHeaderLookupStruct().getHeaders(Http2HeaderName.SET_COOKIE);
String fullRequestCookie = "";
boolean firstLine = true;
for (Http2Header header : headers) {
String value = header.getValue();
if (value.contains(";")) {
String[] split = value.split(";");
value = split[0];
}
String[] keyVal = value.split("=");
if (keyVal.length <= 1)
// skip adding this cookie as it was cleared out
continue;
if (firstLine) {
firstLine = false;
fullRequestCookie += value;
} else
fullRequestCookie += "; " + value;
}
return new Http2Header(Http2HeaderName.COOKIE, fullRequestCookie);
}
Aggregations