@Override public String path() { return delegate.path(); }
/** * Returns the {@link HttpHeaderNames#PATH PATH} of this message. * * @return the path, or {@code null} if there's no such header */ @Nullable default String path() { return headers().path(); }
/** * Sets the path of this request. This method is a shortcut of {@code headers().path(...)}. * * @return {@code this} */ default HttpRequest path(String path) { headers().path(path); return this; }
/** * Returns the path of this request. This method is a shortcut of {@code headers().path()}. */ default String path() { return headers().path(); }
/** * Returns new HTTP request headers. */ static HttpHeaders of(HttpMethod method, String path) { return new DefaultHttpHeaders().method(method).path(path); }
/** * Creates a new builder with the specified {@link HttpRequest}. * * @param server whether this builder will build a server-side context. * @param request the {@link HttpRequest}. */ protected AbstractRequestContextBuilder(boolean server, HttpRequest request) { this.server = server; this.request = requireNonNull(request, "request"); sessionProtocol = SessionProtocol.H2C; final HttpMethod method = request.headers().method(); checkArgument(method != null, "request.method is not valid: %s", request); this.method = method; authority = firstNonNull(request.headers().authority(), FALLBACK_AUTHORITY); final String pathAndQueryStr = request.headers().path(); final PathAndQuery pathAndQuery = PathAndQuery.parse(pathAndQueryStr); checkArgument(pathAndQuery != null, "request.path is not valid: %s", request); path = pathAndQuery.path(); query = pathAndQuery.query(); }
.append(log.requestHeaders().path());
final String path = headers.path(); assert path != null; final HttpRequest req = new DefaultHttpRequest(
private static MetaData.Request toRequestMetadata(ServiceRequestContext ctx, AggregatedHttpMessage aReq) { // Construct the HttpURI final StringBuilder uriBuf = new StringBuilder(); final HttpHeaders aHeaders = aReq.headers(); uriBuf.append(ctx.sessionProtocol().isTls() ? "https" : "http"); uriBuf.append("://"); uriBuf.append(aHeaders.authority()); uriBuf.append(aHeaders.path()); final HttpURI uri = new HttpURI(uriBuf.toString()); uri.setPath(ctx.mappedPath()); // Convert HttpHeaders to HttpFields final HttpFields jHeaders = new HttpFields(aHeaders.size()); aHeaders.forEach(e -> { final AsciiString key = e.getKey(); if (!key.isEmpty() && key.byteAt(0) != ':') { jHeaders.add(key.toString(), e.getValue()); } }); return new MetaData.Request( aHeaders.method().name(), uri, HttpVersion.HTTP_1_1, jHeaders, aReq.content().length()); }
throw new IllegalStateException("not a request (missing :method)"); if (headers.path() == null) { throw new IllegalStateException("not a request (missing :path)");
/** * Converts the headers of the given Netty HTTP/1.x request into Armeria HTTP/2 headers. * The following headers are only used if they can not be found in the {@code HOST} header or the * {@code Request-Line} as defined by <a href="https://tools.ietf.org/html/rfc7230">rfc7230</a> * <ul> * <li>{@link ExtensionHeaderNames#SCHEME}</li> * </ul> * {@link ExtensionHeaderNames#PATH} is ignored and instead extracted from the {@code Request-Line}. */ public static HttpHeaders toArmeria(HttpRequest in) throws URISyntaxException { final URI requestTargetUri = toUri(in); final io.netty.handler.codec.http.HttpHeaders inHeaders = in.headers(); final HttpHeaders out = new DefaultHttpHeaders(true, inHeaders.size()); out.path(toHttp2Path(requestTargetUri)); out.method(HttpMethod.valueOf(in.method().name())); setHttp2Scheme(inHeaders, requestTargetUri, out); if (!isOriginForm(requestTargetUri) && !isAsteriskForm(requestTargetUri)) { // Attempt to take from HOST header before taking from the request-line final String host = inHeaders.getAsString(HttpHeaderNames.HOST); setHttp2Authority(host == null || host.isEmpty() ? requestTargetUri.getAuthority() : host, out); } // Add the HTTP headers which have not been consumed above toArmeria(inHeaders, out); return out; }
final String originalPath = headers.path(); if (originalPath == null) { respond(ctx, req, HttpStatus.BAD_REQUEST,
assertThat(headers.path()).isEqualTo(TEST_PATH_AND_QUERY); assertThat(headers.get(HttpHeaderNames.ACCEPT)).isEqualTo("*/*"); assertThat(headers.get(HttpHeaderNames.USER_AGENT)).isEqualTo("spring/armeria");
assertThat(headers.path()).isEqualTo(TEST_PATH_AND_QUERY); assertThat(headers.get(HttpHeaderNames.ACCEPT)).isEqualTo("*/*");