Search in sources :

Example 16 with HeaderValues

use of io.undertow.util.HeaderValues in project undertow by undertow-io.

the class PushBuilderImpl method push.

@Override
public void push() {
    if (path == null) {
        throw UndertowServletMessages.MESSAGES.pathWasNotSet();
    }
    ServerConnection con = servletRequest.getExchange().getConnection();
    if (con.isPushSupported()) {
        HeaderMap newHeaders = new HeaderMap();
        for (HeaderValues entry : headers) {
            newHeaders.addAll(entry.getHeaderName(), entry);
        }
        if (conditional) {
            if (etag != null) {
                newHeaders.put(Headers.IF_NONE_MATCH, etag);
            } else if (lastModified != null) {
                newHeaders.put(Headers.IF_MODIFIED_SINCE, lastModified);
            }
        }
        if (sessionId != null) {
            //TODO: do this properly, may be a different tracking method or a different cookie name
            newHeaders.put(Headers.COOKIE, "JSESSIONID=" + sessionId);
        }
        String path = this.path;
        if (queryString != null && !queryString.isEmpty()) {
            path += "?" + queryString;
        }
        con.pushResource(path, new HttpString(method), newHeaders);
    }
    path = null;
    etag = null;
    lastModified = null;
}
Also used : HeaderMap(io.undertow.util.HeaderMap) HeaderValues(io.undertow.util.HeaderValues) ServerConnection(io.undertow.server.ServerConnection) HttpString(io.undertow.util.HttpString) HttpString(io.undertow.util.HttpString)

Aggregations

HeaderValues (io.undertow.util.HeaderValues)16 HeaderMap (io.undertow.util.HeaderMap)10 HttpString (io.undertow.util.HttpString)9 HttpServerExchange (io.undertow.server.HttpServerExchange)6 ByteBuffer (java.nio.ByteBuffer)4 PooledByteBuffer (io.undertow.connector.PooledByteBuffer)3 IOException (java.io.IOException)3 HttpSession (javax.servlet.http.HttpSession)3 ExchangeCompletionListener (io.undertow.server.ExchangeCompletionListener)2 HttpHandler (io.undertow.server.HttpHandler)2 Session (io.undertow.server.session.Session)2 HttpSessionImpl (io.undertow.servlet.spec.HttpSessionImpl)2 ImmediatePooledByteBuffer (io.undertow.util.ImmediatePooledByteBuffer)2 InputStream (java.io.InputStream)2 Map (java.util.Map)2 BeforeClass (org.junit.BeforeClass)2 AuthenticationTypeExchangeAttribute (io.undertow.attribute.AuthenticationTypeExchangeAttribute)1 CompositeExchangeAttribute (io.undertow.attribute.CompositeExchangeAttribute)1 ConstantExchangeAttribute (io.undertow.attribute.ConstantExchangeAttribute)1 CookieAttribute (io.undertow.attribute.CookieAttribute)1