@Override public InetAddress getLocalAddress() { return exchange.getLocalAddress() != null ? exchange.getLocalAddress().getAddress() : null; } }
private URI getBaseUri(final HttpExchange exchange, final String decodedBasePath, final String scheme) { final URI baseUri; try { final List<String> hostHeader = exchange.getRequestHeaders().get("Host"); if (hostHeader != null) { baseUri = new URI(scheme + "://" + hostHeader.get(0) + decodedBasePath); } else { final InetSocketAddress addr = exchange.getLocalAddress(); baseUri = new URI(scheme, null, addr.getHostName(), addr.getPort(), decodedBasePath, null, null); } } catch (final URISyntaxException ex) { throw new IllegalArgumentException(ex); } return baseUri; }
baseUri = new URI(sb.toString()); } else { InetSocketAddress addr = exchange.getLocalAddress(); baseUri = new URI(scheme, null, addr.getHostName(), addr.getPort(), decodedBasePath, null, null);
@Override public InetAddress getLocalAddress() { return exchange.getLocalAddress() != null ? exchange.getLocalAddress().getAddress() : null; } }
public static ResteasyUriInfo extractUriInfo(HttpExchange exchange) String host = exchange.getLocalAddress().getHostName(); if (exchange.getLocalAddress().getPort() != 80 && exchange.getLocalAddress().getPort() != 443) host += ":" + exchange.getLocalAddress().getPort();
@Override public InetSocketAddress getLocalAddress() { return delegate.getLocalAddress(); }
@Override public InetAddress getLocalAddress() { return exchange.getLocalAddress() != null ? exchange.getLocalAddress().getAddress() : null; } }
@Override public int getServerPort() { return httpExchange.getLocalAddress().getPort(); }
@Override public int getServerPort() { return httpExchange.getLocalAddress().getPort(); }
@Override public int getServerPort() { return httpExchange.getLocalAddress().getPort(); }
@Override public String getServerName() { return httpExchange.getLocalAddress().getHostName(); }
@Override public String getServerName() { return httpExchange.getLocalAddress().getHostName(); }
@Override public String getServerName() { return httpExchange.getLocalAddress().getHostName(); }
protected String getMereFacadeUrl(String additionalPath) { String requestPaths = m_httpExchange.getRequestURI().getPath().replaceAll(additionalPath, ""); String requestScheme = SunHttpFacadeServerController.fetchRequestScheme(m_httpExchange); return String.format("%s://%s:%s%s", requestScheme, m_httpExchange.getLocalAddress().getHostName(), m_httpExchange.getLocalAddress().getPort(), requestPaths); }
private URI getBaseUri(final HttpExchange exchange, final String decodedBasePath, final String scheme) { final URI baseUri; try { final List<String> hostHeader = exchange.getRequestHeaders().get("Host"); if (hostHeader != null) { baseUri = new URI(scheme + "://" + hostHeader.get(0) + decodedBasePath); } else { final InetSocketAddress addr = exchange.getLocalAddress(); baseUri = new URI(scheme, null, addr.getHostName(), addr.getPort(), decodedBasePath, null, null); } } catch (final URISyntaxException ex) { throw new IllegalArgumentException(ex); } return baseUri; }
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
@Override @NotNull public String getBaseAddress() { /* * Computes the Endpoint's address from the request. Use "Host" header * so that it has correct address(IP address or someother hostname) * through which the application reached the endpoint. * */ StringBuilder strBuf = new StringBuilder(); strBuf.append((httpExchange instanceof HttpsExchange) ? "https" : "http"); strBuf.append("://"); String hostHeader = httpExchange.getRequestHeaders().getFirst("Host"); if (hostHeader != null) { strBuf.append(hostHeader); // Uses Host header } else { strBuf.append(httpExchange.getLocalAddress().getHostName()); strBuf.append(":"); strBuf.append(httpExchange.getLocalAddress().getPort()); } //Do not include URL pattern here //strBuf.append(httpExchange.getRequestURI().getPath()); return strBuf.toString(); }
BasicAuthCredentials theCredentials = null; if ( theAuthHeader == null ) { BasicAuthResponse theBasicAuthResponse = _basicAuthObserver.onBasicAuthRequest( aHttpExchange.getLocalAddress(), aHttpExchange.getRemoteAddress(), HttpMethod.fromHttpMethod( aHttpExchange.getRequestMethod() ), aHttpExchange.getRequestURI().getPath(), theCredentials, getRealm() ); if ( theBasicAuthResponse != BasicAuthResponse.BASIC_AUTH_SUCCESS ) { return toBasicAuthRequired( aHttpExchange ); theCredentials = new BasicAuthCredentialsImpl( theCredentialsText.substring( 0, theMarker ), theCredentialsText.substring( theMarker + 1 ) ); BasicAuthResponse theBasicAuthResponse = _basicAuthObserver.onBasicAuthRequest( aHttpExchange.getLocalAddress(), aHttpExchange.getRemoteAddress(), HttpMethod.fromHttpMethod( aHttpExchange.getRequestMethod() ), aHttpExchange.getRequestURI().getPath(), theCredentials, getRealm() ); if ( theBasicAuthResponse == null ) { throw new NullPointerException( "Your <HttpBasicAuthenticator> instance must return an element of type <BasicAuthResponse> and not null." );
URI theRequestURI = aHttpExchange.getRequestURI(); HttpServerResponse theHttpServerResponse = new HttpServerResponseImpl( HttpRestServerImpl.this ); InetSocketAddress theLocalAddress = aHttpExchange.getLocalAddress(); InetSocketAddress theRemoteAddress = aHttpExchange.getRemoteAddress(); Headers theRequestHeaders = aHttpExchange.getRequestHeaders(); LOGGER.warn( "Unknown HTTP-Method <" + aHttpExchange.getRequestMethod() + "> when querying resource locator <" + aHttpExchange.getLocalAddress() + ">." ); aHttpExchange.sendResponseHeaders( HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), NO_RESPONSE_BODY );