Search in sources :

Example 1 with Header

use of org.glassfish.grizzly.http.util.Header in project Payara by payara.

the class ApplicationPushBuilder method push.

@Override
public void push() {
    if (path == null) {
        throw new IllegalStateException(rb.getString(LogFacade.NO_PUSH_PATH_EXCEPTION));
    }
    Http2Stream http2Stream = (Http2Stream) coyoteRequest.getAttribute(Http2Stream.HTTP2_STREAM_ATTRIBUTE);
    if (http2Stream == null || !http2Stream.isPushEnabled()) {
        return;
    }
    // modify pathLocal rather than path
    String pathLocal = ((path.charAt(0) == '/') ? path : coyoteRequest.getContextPath() + '/' + path);
    if (queryString != null) {
        pathLocal += ((pathLocal.indexOf('?') != -1) ? '&' + queryString : '?' + queryString);
    }
    // Session ID (do this before setting the path since it may change it)
    if (sessionId != null) {
        if (addSessionPathParameter) {
            pathLocal = pathLocal + ";" + sessionCookieName + "=" + sessionId;
        }
        if (addSessionCookie) {
            cookies.add(new Cookie(sessionCookieName, sessionId));
        }
    }
    PushEvent.PushEventBuilder pushEventBuilder = PushEvent.builder();
    pushEventBuilder.method(method);
    pushEventBuilder.headers(headers);
    pushEventBuilder.path(pathLocal);
    pushEventBuilder.httpRequest(coyoteRequest.getRequest());
    coyoteRequest.getContext().notifyDownstream(pushEventBuilder.build());
    // Reset for next call
    path = null;
    for (Header conditionalHeader : CONDITIONAL_HEADERS) {
        headers.removeHeader(conditionalHeader);
    }
}
Also used : Cookie(org.glassfish.grizzly.http.Cookie) PushEvent(org.glassfish.grizzly.http.server.http2.PushEvent) Header(org.glassfish.grizzly.http.util.Header) Http2Stream(org.glassfish.grizzly.http2.Http2Stream)

Aggregations

Cookie (org.glassfish.grizzly.http.Cookie)1 PushEvent (org.glassfish.grizzly.http.server.http2.PushEvent)1 Header (org.glassfish.grizzly.http.util.Header)1 Http2Stream (org.glassfish.grizzly.http2.Http2Stream)1