Search in sources :

Example 1 with Request

use of org.eclipse.jetty.http.MetaData.Request in project jetty.project by eclipse.

the class HTTP2ServerConnection method upgrade.

public boolean upgrade(Request request) {
    if (HttpMethod.PRI.is(request.getMethod())) {
        getParser().directUpgrade();
    } else {
        HttpField settingsField = request.getFields().getField(HttpHeader.HTTP2_SETTINGS);
        if (settingsField == null)
            throw new BadMessageException("Missing " + HttpHeader.HTTP2_SETTINGS + " header");
        String value = settingsField.getValue();
        final byte[] settings = B64Code.decodeRFC4648URL(value == null ? "" : value);
        if (LOG.isDebugEnabled())
            LOG.debug("{} settings {}", this, TypeUtil.toHexString(settings));
        SettingsFrame settingsFrame = SettingsBodyParser.parseBody(BufferUtil.toBuffer(settings));
        if (settingsFrame == null) {
            LOG.warn("Invalid {} header value: {}", HttpHeader.HTTP2_SETTINGS, value);
            throw new BadMessageException();
        }
        getParser().standardUpgrade();
        upgradeFrames.add(new PrefaceFrame());
        upgradeFrames.add(settingsFrame);
        // Remember the request to send a response from onOpen().
        upgradeFrames.add(new HeadersFrame(1, new Request(request), null, true));
    }
    return true;
}
Also used : PrefaceFrame(org.eclipse.jetty.http2.frames.PrefaceFrame) SettingsFrame(org.eclipse.jetty.http2.frames.SettingsFrame) HttpField(org.eclipse.jetty.http.HttpField) BadMessageException(org.eclipse.jetty.http.BadMessageException) Request(org.eclipse.jetty.http.MetaData.Request) HeadersFrame(org.eclipse.jetty.http2.frames.HeadersFrame)

Aggregations

BadMessageException (org.eclipse.jetty.http.BadMessageException)1 HttpField (org.eclipse.jetty.http.HttpField)1 Request (org.eclipse.jetty.http.MetaData.Request)1 HeadersFrame (org.eclipse.jetty.http2.frames.HeadersFrame)1 PrefaceFrame (org.eclipse.jetty.http2.frames.PrefaceFrame)1 SettingsFrame (org.eclipse.jetty.http2.frames.SettingsFrame)1