private EurekaHttpRequest mapToEurekaHttpRequest(HttpExchange httpExchange) { Headers exchangeHeaders = httpExchange.getRequestHeaders(); Map<String, String> headers = new HashMap<>(); for(String key: exchangeHeaders.keySet()) { headers.put(key, exchangeHeaders.getFirst(key)); } return new EurekaHttpRequest(httpExchange.getRequestMethod(), httpExchange.getRequestURI(), headers); }
String method = httpExchange.getRequestMethod(); String path = httpExchange.getRequestURI().getPath(); if (path.startsWith("/v2/apps")) {
/** * Processes the incoming Hessian request and creates a Hessian response. */ @Override public void handle(HttpExchange exchange) throws IOException { if (!"POST".equals(exchange.getRequestMethod())) { exchange.getResponseHeaders().set("Allow", "POST"); exchange.sendResponseHeaders(405, -1); return; } ByteArrayOutputStream output = new ByteArrayOutputStream(1024); try { invoke(exchange.getRequestBody(), output); } catch (Throwable ex) { exchange.sendResponseHeaders(500, -1); logger.error("Hessian skeleton invocation failed", ex); return; } exchange.getResponseHeaders().set("Content-Type", CONTENT_TYPE_HESSIAN); exchange.sendResponseHeaders(200, output.size()); FileCopyUtils.copy(output.toByteArray(), exchange.getResponseBody()); }
public void handle(final HttpExchange httpExchange) throws IOException { // And we pass control to the service, which will (hopefully) start a new thread immediately so we can // continue the receiving thread ASAP log.fine("Received HTTP exchange: " + httpExchange.getRequestMethod() + " " + httpExchange.getRequestURI()); router.received( new HttpExchangeUpnpStream(router.getProtocolFactory(), httpExchange) { @Override protected Connection createConnection() { return new HttpServerConnection(httpExchange); } } ); } }
String requestMethod = exchange.getRequestMethod(); if (requestMethod.equalsIgnoreCase("GET")) { Headers responseHeaders = exchange.getResponseHeaders();
props = getProperties(httpExchange); if ("GET".equalsIgnoreCase(httpExchange.getRequestMethod())) { } else if (httpExchange.getRequestMethod().equals("HEAD")) {
/** * Processes the incoming Hessian request and creates a Hessian response. */ @Override public void handle(HttpExchange exchange) throws IOException { if (!"POST".equals(exchange.getRequestMethod())) { exchange.getResponseHeaders().set("Allow", "POST"); exchange.sendResponseHeaders(405, -1); return; } ByteArrayOutputStream output = new ByteArrayOutputStream(1024); try { invoke(exchange.getRequestBody(), output); } catch (Throwable ex) { exchange.sendResponseHeaders(500, -1); logger.error("Hessian skeleton invocation failed", ex); return; } exchange.getResponseHeaders().set("Content-Type", CONTENT_TYPE_HESSIAN); exchange.sendResponseHeaders(200, output.size()); FileCopyUtils.copy(output.toByteArray(), exchange.getResponseBody()); }
exchange.getRequestMethod(), baseUri, requestUri,
String requestMethod = exchange.getRequestMethod(); try { switch (requestMethod) {
/** * Handles HTTP requests: checks that a request is a HTTP GET and that url path is the expected one. * If all checks are passed it writes pre-configured file content to the HTTP response body. * * @param exchange Wrapper above the HTTP request and response. */ @Override public void handle(HttpExchange exchange) throws IOException { assert "GET".equalsIgnoreCase(exchange.getRequestMethod()); assert urlPath == null || urlPath.equals(exchange.getRequestURI().toString()); exchange.getResponseHeaders().set("Content-Type", "application/octet-stream"); exchange.sendResponseHeaders(200, 0); try (OutputStream resBody = exchange.getResponseBody()) { resBody.write(GridTestUtils.readFile(downloadFile)); } } }
String requestMethod = exchange.getRequestMethod(); switch (requestMethod) { case "GET":
exchange.getRequestMethod(), getSecurityContext(exchange.getPrincipal(), isSecure), new MapPropertiesDelegate()); requestContext.setEntityStream(exchange.getRequestBody());
public void run() { log.fine("Processing HTTP request: " + getHttpExchange().getRequestMethod() + " " + getHttpExchange().getRequestURI()); UpnpRequest.Method.getByHttpName(getHttpExchange().getRequestMethod()), getHttpExchange().getRequestURI() ); log.fine("Method not supported by UPnP stack: " + getHttpExchange().getRequestMethod()); throw new RuntimeException("Method not supported: " + getHttpExchange().getRequestMethod());
public HttpServerRequest(final SynchronousDispatcher dispatcher, final HttpResponse httpResponse, final HttpExchange exchange) { super(HttpExchangeUtil.extractUriInfo(exchange)); this.dispatcher = dispatcher; this.httpResponse = httpResponse; this.exchange = exchange; this.httpHeaders = HttpExchangeUtil.extractHttpHeaders(exchange); this.preProcessedPath = uri.getPath(false); this.httpMethod = exchange.getRequestMethod().toUpperCase(); }
public void handle(final HttpExchange httpExchange) throws IOException { // And we pass control to the service, which will (hopefully) start a new thread immediately so we can // continue the receiving thread ASAP log.fine("Received HTTP exchange: " + httpExchange.getRequestMethod() + " " + httpExchange.getRequestURI()); router.received( new HttpExchangeUpnpStream(router.getProtocolFactory(), httpExchange) { @Override protected Connection createConnection() { return new HttpServerConnection(httpExchange); } } ); } }
address.getAddress().getHostAddress(), extractOriginOrReferer(pExchange)); String method = pExchange.getRequestMethod();
public void run() { log.fine("Processing HTTP request: " + getHttpExchange().getRequestMethod() + " " + getHttpExchange().getRequestURI()); UpnpRequest.Method.getByHttpName(getHttpExchange().getRequestMethod()), getHttpExchange().getRequestURI() ); log.fine("Method not supported by UPnP stack: " + getHttpExchange().getRequestMethod()); throw new RuntimeException("Method not supported: " + getHttpExchange().getRequestMethod());
@Override @Property(MessageContext.HTTP_REQUEST_METHOD) public @NotNull String getRequestMethod() { return httpExchange.getRequestMethod(); }
private EurekaHttpRequest mapToEurekaHttpRequest(HttpExchange httpExchange) { Headers exchangeHeaders = httpExchange.getRequestHeaders(); Map<String, String> headers = new HashMap<>(); for(String key: exchangeHeaders.keySet()) { headers.put(key, exchangeHeaders.getFirst(key)); } return new EurekaHttpRequest(httpExchange.getRequestMethod(), httpExchange.getRequestURI(), headers); }
static Request convert(final HttpExchange httpExchange) throws IOException { final Request.Builder builder = Request.builder() .method(httpExchange.getRequestMethod()) .requestURI(httpExchange.getRequestURI()) .body(IOUtils.toByteArray(httpExchange.getRequestBody())); addEncoding(builder, httpExchange); addHeaders(builder, httpExchange); return builder.build(); }