@Override public MultiMap add(String name, String value) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, value); } headers.add(toLowerCase(name), value); return this; }
protected Http2Headers getHeadersForPushNotification(final ApnsPushNotification pushNotification, final int streamId) { final Http2Headers headers = new DefaultHttp2Headers() .method(HttpMethod.POST.asciiName()) .authority(this.authority) .path(APNS_PATH_PREFIX + pushNotification.getToken()) .scheme(HttpScheme.HTTPS.name()) .addInt(APNS_EXPIRATION_HEADER, pushNotification.getExpiration() == null ? 0 : (int) (pushNotification.getExpiration().getTime() / 1000)); if (pushNotification.getCollapseId() != null) { headers.add(APNS_COLLAPSE_ID_HEADER, pushNotification.getCollapseId()); } if (pushNotification.getPriority() != null) { headers.addInt(APNS_PRIORITY_HEADER, pushNotification.getPriority().getCode()); } if (pushNotification.getTopic() != null) { headers.add(APNS_TOPIC_HEADER, pushNotification.getTopic()); } if (pushNotification.getApnsId() != null) { headers.add(APNS_ID_HEADER, FastUUID.toString(pushNotification.getApnsId())); } return headers; }
@Override public MultiMap add(CharSequence name, Iterable<CharSequence> values) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, values); } headers.add(toLowerCase(name), values); return this; }
@Override public MultiMap add(String name, Iterable<String> values) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, values); } headers.add(toLowerCase(name), values); return this; }
@Override public MultiMap add(CharSequence name, CharSequence value) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, value); } headers.add(toLowerCase(name), value); return this; }
@Override public void appendToHeaderList(CharSequence name, CharSequence value) { headersLength += HpackHeaderField.sizeOf(name, value); exceededMaxLength |= headersLength > maxHeaderListSize; if (exceededMaxLength || validationException != null) { // We don't store the header since we've already failed validation requirements. return; } if (validate) { try { previousType = HpackDecoder.validate(streamId, name, previousType); } catch (Http2Exception ex) { validationException = ex; return; } } headers.add(name, value); } }
@Override protected Http2Headers getHeadersForPushNotification(final ApnsPushNotification pushNotification, final int streamId) { final Http2Headers headers = super.getHeadersForPushNotification(pushNotification, streamId); if (this.authenticationToken == null) { try { this.authenticationToken = new AuthenticationToken(signingKey, new Date()); this.mostRecentStreamWithNewToken = streamId; } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) { // This should never happen because we check the key/algorithm at signing key construction time. log.error("Failed to generate authentication token.", e); throw new RuntimeException(e); } } headers.add(APNS_AUTHORIZATION_HEADER, this.authenticationToken.getAuthorizationHeader()); return headers; }
/** * Filter the {@link HttpHeaderNames#TE} header according to the * <a href="https://tools.ietf.org/html/rfc7540#section-8.1.2.2">special rules in the HTTP/2 RFC</a>. * @param entry An entry whose name is {@link HttpHeaderNames#TE}. * @param out the resulting HTTP/2 headers. */ private static void toHttp2HeadersFilterTE(Entry<CharSequence, CharSequence> entry, Http2Headers out) { if (indexOf(entry.getValue(), ',', 0) == -1) { if (contentEqualsIgnoreCase(trim(entry.getValue()), TRAILERS)) { out.add(TE, TRAILERS); } } else { List<CharSequence> teValues = unescapeCsvFields(entry.getValue()); for (CharSequence teValue : teValues) { if (contentEqualsIgnoreCase(trim(teValue), TRAILERS)) { out.add(TE, TRAILERS); break; } } } }
headers.forEach(header -> headers_.add(header.getKey(), header.getValue()));
@Override public void push(final String method, final String path, final Map<String, Object> headers) { ctx.channel().eventLoop().execute(() -> { AsciiString streamIdHeader = HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text(); Http2Connection connection = encoder.connection(); int nextStreamId = connection.local().incrementAndGetNextStreamId(); Http2Headers h2headers = new DefaultHttp2Headers() .path(path) .method(method) .authority(authority) .scheme(scheme); headers.forEach((n, v) -> h2headers.add(n, v.toString())); encoder.writePushPromise(ctx, streamId, nextStreamId, h2headers, 0, ctx.newPromise()); // TODO: Is there another way of handling a push promise? DefaultFullHttpRequest pushRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.valueOf(method.toUpperCase()), path, Unpooled.EMPTY_BUFFER, new DefaultHttpHeaders(false).set(streamIdHeader, nextStreamId), EmptyHttpHeaders.INSTANCE); ctx.pipeline().fireChannelRead(pushRequest); ctx.pipeline().fireChannelReadComplete(); }); }
h.add(Http2HeadersAdaptor.toLowerCase(header.getKey()), header.getValue());
@Override public MultiMap add(CharSequence name, Iterable<CharSequence> values) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, values); } headers.add(toLowerCase(name), values); return this; }
@Override public MultiMap add(String name, String value) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, value); } headers.add(toLowerCase(name), value); return this; }
@Override public MultiMap add(String name, Iterable<String> values) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, values); } headers.add(toLowerCase(name), values); return this; }
@Override public MultiMap add(CharSequence name, CharSequence value) { if (!io.vertx.core.http.HttpHeaders.DISABLE_HTTP_HEADERS_VALIDATION) { HttpUtils.validateHeader(name, value); } headers.add(toLowerCase(name), value); return this; }
headers.forEach(header -> headers_.add(header.getKey(), header.getValue()));
h.add(Http2HeadersAdaptor.toLowerCase(header.getKey()), header.getValue());