/** * Returns the full protocol version text such as {@code "HTTP/1.0"}. */ @Override public String toString() { return text(); }
@Override public String getProtocolText() { return response.protocolVersion().text(); }
@Override public String protocol() { return ctx.pipeline().get("h2") == null ? req.protocolVersion().text() : "HTTP/2.0"; }
/** * Returns true if the server switched to a different protocol than HTTP/1.0 or HTTP/1.1, e.g. HTTP/2 or Websocket. * Returns false if the upgrade happened in a different layer, e.g. upgrade from HTTP/1.1 to HTTP/1.1 over TLS. */ protected boolean isSwitchingToNonHttp1Protocol(HttpResponse msg) { if (msg.status().code() != HttpResponseStatus.SWITCHING_PROTOCOLS.code()) { return false; } String newProtocol = msg.headers().get(HttpHeaderNames.UPGRADE); return newProtocol == null || !newProtocol.contains(HttpVersion.HTTP_1_0.text()) && !newProtocol.contains(HttpVersion.HTTP_1_1.text()); }
private static HttpProtocolVersion toHttpProtocolVersion(final HttpVersion httpVersion) { return HttpProtocolVersion.versionOf(httpVersion.text()); }
@Override public Http.Version version() { return Http.Version.create(nettyRequest.protocolVersion().text()); }
/** * Creates a new {@link HarRequest} object for this failed HTTP CONNECT. Does not populate fields within the request, * such as the error message. * * @param httpConnectRequest the HTTP CONNECT request that failed * @return a new HAR request object */ private HarRequest createRequestForFailedConnect(HttpRequest httpConnectRequest) { String url = getFullUrl(httpConnectRequest); return new HarRequest(httpConnectRequest.getMethod().toString(), url, httpConnectRequest.getProtocolVersion().text()); }
protocol = nativeRequest.protocolVersion().text();
/** * Creates a HarRequest object using the method, url, and HTTP version of the specified request. * * @param httpRequest HTTP request on which the HarRequest will be based * @return a new HarRequest object */ private HarRequest createHarRequestForHttpRequest(HttpRequest httpRequest) { // the HAR spec defines the request.url field as: // url [string] - Absolute URL of the request (fragments are not included). // the URI on the httpRequest may only identify the path of the resource, so find the full URL. // the full URL consists of the scheme + host + port (if non-standard) + path + query params + fragment. String url = getFullUrl(httpRequest); return new HarRequest(httpRequest.getMethod().toString(), url, httpRequest.getProtocolVersion().text()); }
this.protocol = nettyRequest.protocolVersion().text(); this.method = nettyRequest.method().name();
this.protocol = nettyRequest.protocolVersion().text(); this.method = nettyRequest.method().name();
protected void captureResponse(HttpResponse httpResponse) { HarResponse response = new HarResponse(httpResponse.getStatus().code(), httpResponse.getStatus().reasonPhrase(), httpResponse.getProtocolVersion().text()); harEntry.setResponse(response); captureResponseHeaderSize(httpResponse); captureResponseMimeType(httpResponse); if (dataToCapture.contains(CaptureType.RESPONSE_COOKIES)) { captureResponseCookies(httpResponse); } if (dataToCapture.contains(CaptureType.RESPONSE_HEADERS)) { captureResponseHeaders(httpResponse); } if (BrowserMobHttpUtil.isRedirect(httpResponse)) { captureRedirectUrl(httpResponse); } }
frameHeaders.set(SpdyHeaders.HttpNames.VERSION, httpResponse.protocolVersion().text());
protocol = nativeRequest.protocolVersion().text();
frameHeaders.set(SpdyHeaders.HttpNames.METHOD, httpRequest.method().name()); frameHeaders.set(SpdyHeaders.HttpNames.PATH, httpRequest.uri()); frameHeaders.set(SpdyHeaders.HttpNames.VERSION, httpRequest.protocolVersion().text());
public static HttpRequest newRequest(final FullHttpRequest request) { QueryStringDecoder decoder = new QueryStringDecoder(request.uri()); ImmutableMap<String, String[]> queries = toQueries(decoder); return builder() .withVersion(HttpProtocolVersion.versionOf(request.protocolVersion().text())) .withHeaders(toHeaders(request)) .withMethod(HttpMethod.valueOf(request.method().toString().toUpperCase())) .withUri(decoder.path()) .withQueries(queries) .withContent(toMessageContent(request)) .build(); }
/** * Returns true if the server switched to a different protocol than HTTP/1.0 or HTTP/1.1, e.g. HTTP/2 or Websocket. * Returns false if the upgrade happened in a different layer, e.g. upgrade from HTTP/1.1 to HTTP/1.1 over TLS. */ protected boolean isSwitchingToNonHttp1Protocol(HttpResponse msg) { if (msg.status().code() != HttpResponseStatus.SWITCHING_PROTOCOLS.code()) { return false; } String newProtocol = msg.headers().get(HttpHeaderNames.UPGRADE); return newProtocol == null || !newProtocol.contains(HttpVersion.HTTP_1_0.text()) && !newProtocol.contains(HttpVersion.HTTP_1_1.text()); }
@Override public String getProtocol() { if (requestInfo.getProtocolVersion() == null) return null; return requestInfo.getProtocolVersion().text(); }
public Session(String remoteIp, HttpRequest request) { this.remoteIp = remoteIp; this.uri = request.uri(); if (request.decoderResult().isSuccess()) { method = request.method().name(); protocol = request.protocolVersion().text(); } else { method = "GET"; protocol = "HTTP/1.1"; } requestId = UUID.randomUUID().toString(); startTime = System.currentTimeMillis(); }
/** * Creates a new {@link HarRequest} object for this failed HTTP CONNECT. Does not populate fields within the request, * such as the error message. * * @param httpConnectRequest the HTTP CONNECT request that failed * @return a new HAR request object */ private HarRequest createRequestForFailedConnect(HttpRequest httpConnectRequest) { String url = getFullUrl(httpConnectRequest); return new HarRequest(httpConnectRequest.getMethod().toString(), url, httpConnectRequest.getProtocolVersion().text()); }