@Override public InetAddress getRemoteAddress() { return exchange.getRemoteAddress() != null ? exchange.getRemoteAddress().getAddress() : null; }
private int maybeAlterStanfordTimeout(HttpExchange httpExchange, int timeoutMilliseconds) { if ( ! stanford) { return timeoutMilliseconds; } try { // Check for too long a timeout from an unauthorized source if (timeoutMilliseconds > 15000) { // If two conditions: // (1) The server is running on corenlp.run (i.e., corenlp.stanford.edu) // (2) The request is not coming from a *.stanford.edu" email address // Then force the timeout to be 15 seconds if ("corenlp.stanford.edu".equals(InetAddress.getLocalHost().getHostName()) && ! httpExchange.getRemoteAddress().getHostName().toLowerCase().endsWith("stanford.edu")) { timeoutMilliseconds = 15000; } } return timeoutMilliseconds; } catch (UnknownHostException uhe) { return timeoutMilliseconds; } }
/** @see #onBlacklist(Inet4Address) */ private boolean onBlacklist(HttpExchange exchange) { if ( ! stanford) { return false; } InetAddress addr = exchange.getRemoteAddress().getAddress(); if (addr instanceof Inet4Address) { return onBlacklist((Inet4Address) addr); } else { log("Not checking IPv6 address against blacklist: " + addr); return false; // TODO(gabor) we should eventually check ipv6 addresses too } }
/** * A helper function to respond to a request with an error stating that the user is not authorized * to make this request. * * @param httpExchange The exchange to send the error over. * * @throws IOException Thrown if the HttpExchange cannot communicate the error. */ private static void respondUnauthorized(HttpExchange httpExchange) throws IOException { log("Responding unauthorized to " + httpExchange.getRemoteAddress()); httpExchange.getResponseHeaders().add("Content-type", "application/javascript"); byte[] content = "{\"message\": \"Unauthorized API request\"}".getBytes("utf-8"); httpExchange.sendResponseHeaders(HTTP_UNAUTHORIZED, content.length); httpExchange.getResponseBody().write(content); httpExchange.close(); }
log("[" + httpExchange.getRemoteAddress() + "] API call w/annotators " + props.getProperty("annotators", "<unknown>"));
@Override public InetAddress getRemoteAddress() { return exchange.getRemoteAddress() != null ? exchange.getRemoteAddress().getAddress() : null; }
HttpExchange exchange = (HttpExchange)msgx.get("com.sun.xml.ws.http.exchange"); InetSocketAddress remoteAddress = exchange.getRemoteAddress(); String remoteHost = remoteAddress.getHostName();
HttpExchange exchange = (HttpExchange)msgx.get(JAXWSProperties.HTTP_EXCHANGE); InetSocketAddress remoteAddress = exchange.getRemoteAddress(); String remoteHost = remoteAddress.getHostName();
@Override public void handle(final HttpExchange httpExchange) throws IOException { final String remoteClientAddress = httpExchange.getRemoteAddress().getAddress().toString().replace("/", ""); LOG.debug("Prometheus exporter received client request from: " + remoteClientAddress); String response = "Forbidden"; int responseCode = 403; if (Arrays.asList(PrometheusExporterAllowedAddresses.value().split(",")).contains(remoteClientAddress)) { prometheusExporter.updateMetrics(); response = prometheusExporter.getMetrics(); responseCode = 200; } httpExchange.getResponseHeaders().set("Content-Type", "text/plain"); httpExchange.sendResponseHeaders(responseCode, response.length()); final OutputStream os = httpExchange.getResponseBody(); os.write(response.getBytes()); os.close(); } }
@Override public void handle(HttpExchange t) throws IOException { try { Thread.currentThread().setName("Cmd Thread " + Thread.currentThread().getId() + " " + t.getRemoteAddress()); s_logger.info("CmdHandler " + t.getRequestURI()); doHandle(t); } catch (Exception e) { s_logger.error(e.toString(), e); String response = "Not found"; t.sendResponseHeaders(404, response.length()); OutputStream os = t.getResponseBody(); os.write(response.getBytes()); os.close(); } catch (OutOfMemoryError e) { s_logger.error("Unrecoverable OutOfMemory Error, exit and let it be re-launched"); System.exit(1); } catch (Throwable e) { s_logger.error(e.toString(), e); } finally { t.close(); } }
public void handle(HttpExchange t) throws IOException { try { Thread.currentThread().setName("JPG Thread " + Thread.currentThread().getId() + " " + t.getRemoteAddress());
try { InetSocketAddress address = pExchange.getRemoteAddress(); requestHandler.checkAccess(getHostName(address), address.getAddress().getHostAddress(),
@Override public InetSocketAddress getRemoteAddress() { return delegate.getRemoteAddress(); }
@Override public InetAddress getRemoteAddress() { return exchange.getRemoteAddress() != null ? exchange.getRemoteAddress().getAddress() : null; }
/** * Returns the fully qualified name of the client or the last proxy that sent the request. * @return the fully qualified name of the client or the last proxy that sent the request. */ public String getRemoteHost() { return _exchange.getRemoteAddress().getHostName(); }
/** * Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request. * @return the Internet Protocol (IP) source port of the client or last proxy that sent the request. */ public int getRemotePort() { return _exchange.getRemoteAddress().getPort(); }
/** * Returns the Internet Protocol (IP) address of the client or last proxy that sent the request. * @return the Internet Protocol (IP) address of the client or last proxy that sent the request. */ public String getRemoteAddr() { return _exchange.getRemoteAddress().getAddress().getHostAddress(); }
private String getIP(){ MessageContext mc = wsContext.getMessageContext(); HttpExchange exchange = (HttpExchange)mc.get("com.sun.xml.internal.ws.http.exchange"); System.out.print(exchange.getRemoteAddress().getAddress().getHostAddress()); return exchange.getRemoteAddress().getAddress().getHostAddress(); }
public Request(HttpExchange exchange, Locale locale) { this.requestMethod = exchange.getRequestMethod(); this.target = exchange.getRequestURI().getPath(); remoteAddress = exchange.getRemoteAddress().getAddress().getHostAddress(); this.exchange = exchange; this.locale = locale; }
/** @see #onBlacklist(Inet4Address) */ private boolean onBlacklist(HttpExchange exchange) { if ( ! stanford) { return false; } InetAddress addr = exchange.getRemoteAddress().getAddress(); if (addr instanceof Inet4Address) { return onBlacklist((Inet4Address) addr); } else { log("Not checking IPv6 address against blacklist: " + addr); return false; // TODO(gabor) we should eventually check ipv6 addresses too } }