@Override public HttpMethod getMethod() { HttpMethod method = HttpMethod.resolve(this.jettyRequest.getMethod()); Assert.state(method != null, "Method must not be null"); return method; }
@Override public HttpMethod getMethod() { HttpMethod method = HttpMethod.resolve(this.jettyRequest.getMethod()); Assert.state(method != null, "Method must not be null"); return method; }
@Override public String getMethod(Request request) { return request.getMethod(); }
@Override public HttpMethod getMethod() { HttpMethod method = HttpMethod.resolve(this.jettyRequest.getMethod()); Assert.state(method != null, "Method must not be null"); return method; }
@Override public HttpMethod getMethod() { HttpMethod method = HttpMethod.resolve(this.jettyRequest.getMethod()); Assert.state(method != null, "Method must not be null"); return method; }
String path = request.getPath(); String uri = (query == null) ? path : path + "?" + query; String A2 = request.getMethod() + ":" + uri; if ("auth-int".equals(qop)) A2 += ":" + toHexString(digester.digest(content));
String hashA1 = toHexString(digester.digest(A1.getBytes(charset))); String A2 = request.getMethod().asString() + ":" + request.getURI(); if ("auth-int".equals(qop)) A2 += ":" + toHexString(digester.digest(content));
HttpFields headers = response.getHeaders(); long length = headers.getLongField(HttpHeader.CONTENT_LENGTH.asString()); if (HttpMethod.HEAD.is(request.getMethod())) length = 0; if (length > maxLength)
String hashA1 = toHexString(digester.digest(A1.getBytes(charset))); String A2 = request.getMethod().asString() + ":" + request.getURI(); if ("auth-int".equals(qop)) A2 += ":" + toHexString(digester.digest(content));
private String requestStatus(Request request, Response r, boolean uriIsSecret) { String safeUri = safeUri(request, uriIsSecret); return request.getMethod() + " " + safeUri + ": " + r.getStatus() + " " + HttpStatus.getMessage(r.getStatus()); }
String method = request.getMethod(); if (method != null) { method = method.toUpperCase(Locale.US);
if (request.getMethod() == HttpMethod.GET || request.getMethod() == HttpMethod.HEAD) redirect(result, request.getMethod(), newURI); else fail(result, new HttpResponseException("HTTP protocol violation: received 301 for non GET or HEAD request", response)); redirect(result, request.getMethod(), newURI); break;
if (request.getMethod() == HttpMethod.GET || request.getMethod() == HttpMethod.HEAD) redirect(result, request.getMethod(), newURI); else fail(result, new HttpResponseException("HTTP protocol violation: received 301 for non GET or HEAD request", response)); redirect(result, request.getMethod(), newURI); break;
@Test public void testExtraction() { HttpFields fields = new HttpFields(); fields.add(new HttpField("User-Agent", "Test 1.0")); Request request = mock(Request.class); Response response = mock(Response.class); OcJettyHttpClientExtractor extractor = new OcJettyHttpClientExtractor(); when(request.getHost()).thenReturn("localhost"); when(request.getMethod()).thenReturn("GET"); when(request.getHeaders()).thenReturn(fields); when(request.getPath()).thenReturn("/test"); when(request.getURI()).thenReturn(uri); when(response.getStatus()).thenReturn(0); assertThat(extractor.getHost(request)).contains("localhost"); assertThat(extractor.getMethod(request)).contains("GET"); assertThat(extractor.getPath(request)).contains("/test"); assertThat(extractor.getUrl(request)).contains(URI_STR); assertThat(extractor.getRoute(request)).contains(""); assertThat(extractor.getUserAgent(request)).contains("Test 1.0"); assertThat(extractor.getStatusCode(response)).isEqualTo(0); } }
String method = request.getMethod(); if (HttpMethod.GET.is(method) || HttpMethod.HEAD.is(method) || HttpMethod.PUT.is(method)) return redirect(request, response, listener, newURI, method); String method = request.getMethod(); if (HttpMethod.HEAD.is(method) || HttpMethod.PUT.is(method)) return redirect(request, response, listener, newURI, method); String method = request.getMethod(); if (HttpMethod.HEAD.is(method)) return redirect(request, response, listener, newURI, method); return redirect(request, response, listener, newURI, request.getMethod());
protected Request copyRequest(Request oldRequest, URI newURI) { Request newRequest = new HttpRequest(this, oldRequest.getConversationID(), newURI); newRequest.method(oldRequest.getMethod()) .version(oldRequest.getVersion()) .content(oldRequest.getContent()); for (HttpField header : oldRequest.getHeaders()) { // We have a new URI, so skip the host header if present if (HttpHeader.HOST == header.getHeader()) continue; // Remove expectation headers if (HttpHeader.EXPECT == header.getHeader()) continue; // Remove cookies if (HttpHeader.COOKIE == header.getHeader()) continue; // Remove authorization headers if (HttpHeader.AUTHORIZATION == header.getHeader() || HttpHeader.PROXY_AUTHORIZATION == header.getHeader()) continue; newRequest.header(header.getName(), header.getValue()); } return newRequest; }
protected Request copyRequest(Request oldRequest, URI newURI) { Request newRequest = new HttpRequest(this, oldRequest.getConversationID(), newURI); newRequest.method(oldRequest.getMethod()) .version(oldRequest.getVersion()) .content(oldRequest.getContent()); for (HttpField header : oldRequest.getHeaders()) { // We have a new URI, so skip the host header if present if (HttpHeader.HOST == header.getHeader()) continue; // Remove expectation headers if (HttpHeader.EXPECT == header.getHeader()) continue; // Remove cookies if (HttpHeader.COOKIE == header.getHeader()) continue; // Remove authorization headers if (HttpHeader.AUTHORIZATION == header.getHeader() || HttpHeader.PROXY_AUTHORIZATION == header.getHeader()) continue; newRequest.header(header.getName(), header.getValue()); } return newRequest; }
@Override public boolean startResponse(HttpVersion version, int status, String reason) { if (updateState(State.IDLE, State.RECEIVE)) { HttpExchange exchange = connection.getExchange(); // The exchange may be null if it failed concurrently if (exchange != null) { HttpConversation conversation = exchange.getConversation(); HttpResponse response = exchange.getResponse(); parser.setHeadResponse(exchange.getRequest().getMethod() == HttpMethod.HEAD); response.version(version).status(status).reason(reason); // Probe the protocol handlers HttpClient client = connection.getHttpClient(); ProtocolHandler protocolHandler = client.findProtocolHandler(exchange.getRequest(), response); Response.Listener handlerListener = null; if (protocolHandler != null) { handlerListener = protocolHandler.getResponseListener(); LOG.debug("Found protocol handler {}", protocolHandler); } exchange.getConversation().updateResponseListeners(handlerListener); LOG.debug("Receiving {}", response); ResponseNotifier notifier = connection.getDestination().getResponseNotifier(); notifier.notifyBegin(conversation.getResponseListeners(), response); } } return false; }
@Override public boolean startResponse(HttpVersion version, int status, String reason) { if (updateState(State.IDLE, State.RECEIVE)) { HttpExchange exchange = connection.getExchange(); // The exchange may be null if it failed concurrently if (exchange != null) { HttpConversation conversation = exchange.getConversation(); HttpResponse response = exchange.getResponse(); parser.setHeadResponse(exchange.getRequest().getMethod() == HttpMethod.HEAD); response.version(version).status(status).reason(reason); // Probe the protocol handlers HttpClient client = connection.getHttpClient(); ProtocolHandler protocolHandler = client.findProtocolHandler(exchange.getRequest(), response); Response.Listener handlerListener = null; if (protocolHandler != null) { handlerListener = protocolHandler.getResponseListener(); LOG.debug("Found protocol handler {}", protocolHandler); } exchange.getConversation().updateResponseListeners(handlerListener); LOG.debug("Receiving {}", response); ResponseNotifier notifier = connection.getDestination().getResponseNotifier(); notifier.notifyBegin(conversation.getResponseListeners(), response); } } return false; }