private Timer requestTimer(String method) { final HttpMethod m = HttpMethod.fromString(method); if (m == null) { return otherRequests; } else { switch (m) { case GET: return getRequests; case POST: return postRequests; case PUT: return putRequests; case HEAD: return headRequests; case DELETE: return deleteRequests; case OPTIONS: return optionsRequests; case TRACE: return traceRequests; case CONNECT: return connectRequests; case MOVE: return moveRequests; default: return otherRequests; } } }
private Timer requestTimer(String method) { final HttpMethod m = HttpMethod.fromString(method); if (m == null) { return otherRequests; } else { switch (m) { case GET: return getRequests; case POST: return postRequests; case PUT: return putRequests; case HEAD: return headRequests; case DELETE: return deleteRequests; case OPTIONS: return optionsRequests; case TRACE: return traceRequests; case CONNECT: return connectRequests; case MOVE: return moveRequests; default: return otherRequests; } } }
/** * Factory method to create a {@link HttpMethod}-object according to the given String <code>httpMethodString</code> * * @param httpMethodString the name of the {@link HttpMethod} to create * @throws IllegalArgumentException if <code>httpMethod</code> is none of <code>GET</code>, <code>PUT</code>, * <code>POST</POST> or <code>DELETE</code> */ public static HttpMethod createHttpMethod(String httpMethodString) { // @formatter:off return Optional.ofNullable(HttpMethod.fromString(httpMethodString)) .filter(m -> m == GET || m == POST || m == PUT || m == DELETE) .orElseThrow(() -> new IllegalArgumentException("Given HTTP Method '" + httpMethodString + "' is unknown")); // @formatter:on }
HttpMethod m = HttpMethod.fromString(method); base_request.setMethod(m,m.asString());
connector,configuration,endPoint,transport,input); HttpMethod method = HttpMethod.fromString(request.getMethod()); HttpVersion version = HttpVersion.fromString(request.getHttpVersion()); httpChannel.startRequest(method,request.getMethod(),BufferUtil.toBuffer(request.getRequestURI().toASCIIString()),version);
connector,configuration,endPoint,transport,input); HttpMethod method = HttpMethod.fromString(request.getMethod()); HttpVersion version = HttpVersion.fromString(request.getHttpVersion()); httpChannel.startRequest(method,request.getMethod(),BufferUtil.toBuffer(request.getRequestURI().toASCIIString()),version);
final Request webReq = httpClient(). newRequest(url). method(HttpMethod.fromString(req.getMethod())). header("X-Experience-API-Version", this.version.toString());
final Request request = httpClient.newRequest(host, port) .path(path) .method(HttpMethod.fromString(method)); addNonSpdyHeadersToRequest(version, headers, request);
private boolean performBeginRequest(Fields headers) { short version = stream.getSession().getVersion(); Fields.Field methodHeader = headers.get(HTTPSPDYHeader.METHOD.name(version)); Fields.Field uriHeader = headers.get(HTTPSPDYHeader.URI.name(version)); Fields.Field versionHeader = headers.get(HTTPSPDYHeader.VERSION.name(version)); if (methodHeader == null || uriHeader == null || versionHeader == null) { badMessage(400, "Missing required request line elements"); return false; } HttpMethod httpMethod = HttpMethod.fromString(methodHeader.getValue()); HttpVersion httpVersion = HttpVersion.fromString(versionHeader.getValue()); // TODO should handle URI as byte buffer as some bad clients send WRONG encodings in query string // that we have to deal with ByteBuffer uri = BufferUtil.toBuffer(uriHeader.getValue()); if (LOG.isDebugEnabled()) LOG.debug("HTTP > {} {} {}", httpMethod, uriHeader.getValue(), httpVersion); startRequest(httpMethod, httpMethod.asString(), uri, httpVersion); Fields.Field schemeHeader = headers.get(HTTPSPDYHeader.SCHEME.name(version)); if (schemeHeader != null) getRequest().setScheme(schemeHeader.getValue()); return true; }