public static HttpRequest newJDiscRequest(CurrentContainer container, HttpServletRequest servletRequest) { try { HttpRequest httpRequest = HttpRequest.newServerRequest( container, getUri(servletRequest), HttpRequest.Method.valueOf(servletRequest.getMethod()), HttpRequest.Version.fromString(servletRequest.getProtocol()), new InetSocketAddress(servletRequest.getRemoteAddr(), servletRequest.getRemotePort()), getConnection(servletRequest).getCreatedTimeStamp()); httpRequest.context().put(ServletRequest.JDISC_REQUEST_X509CERT, getCertChain(servletRequest)); return httpRequest; } catch (Utf8Appendable.NotUtf8Exception e) { throw createBadQueryException(e); } }
@Override public int hashCode() { return path.hashCode() + method.hashCode(); }
private static com.yahoo.jdisc.Request createDiscRequest(Request request, CurrentContainer currentContainer) { String scheme = getScheme(request.getUri()); com.yahoo.jdisc.Request discRequest; if ("http".equals(scheme) || "https".equals(scheme)) { com.yahoo.jdisc.http.HttpRequest httpRequest = com.yahoo.jdisc.http.HttpRequest.newServerRequest(currentContainer, URI.create(request.getUri()), com.yahoo.jdisc.http.HttpRequest.Method.valueOf(request.getMethod().name())); request.getUserPrincipal().ifPresent(httpRequest::setUserPrincipal); discRequest = httpRequest; } else { discRequest = new com.yahoo.jdisc.Request(currentContainer, URI.create(request.getUri())); } for (Map.Entry<String, List<String>> entry : request.getHeaders().entrySet()) { discRequest.headers().add(entry.getKey(), entry.getValue()); } discRequest.context().putAll(request.getAttributes()); return discRequest; }
public static String getHttpMethod(final HttpRequest httpRequest) { return httpRequest.getMethod().toString(); }
@Override public String getMethod() { return parent.getMethod().name(); }
private void parseEntry(String entry) { String [] components = entry.split(":", 4); MockServiceHandler.Key key = new TextKey(com.yahoo.jdisc.http.HttpRequest.Method.valueOf(components[0]), components[1]); Value value = new Value(Integer.parseInt(components[2]), components[3].getBytes(), "text/plain"); store.put(key, value); }
@Override public String toString() { return method.toString() + ":" + path; } }
@Override public Optional<Method> getMethod() { return Optional.of(Method.valueOf(request.getMethod())); }