String decodedBasePath = exchange.getHttpContext().getPath();
String decodedBasePath = exchange.getHttpContext().getPath();
@Override public void handle(HttpExchange he) throws IOException { System.out.println("Request " + count++); System.out.println(he.getHttpContext().getPath()); InputStream is = he.getRequestBody(); String response = "<font color='red'>Lets Learn Java8.</font>"; he.sendResponseHeaders(200, response.length()); OutputStream os = he.getResponseBody(); os.write(response.getBytes()); os.close(); } }
String protocol = exchange.getHttpContext().getServer() instanceof HttpsServer ? "https" : "http"; String contextPath = exchange.getHttpContext().getPath(); String path = PathHelper.getEncodedPathInfo(absoluteURI.getRawPath(), contextPath); if (!path.startsWith("/"))
public static String fetchRequestScheme(HttpExchange httpExchange) { if (httpExchange.getHttpContext().getServer() instanceof HttpsServer) { return URL_SCHEME_HTTPS; } return URL_SCHEME_HTTP; }
@Override @Property(MessageContext.PATH_INFO) public String getPathInfo() { URI requestUri = httpExchange.getRequestURI(); String reqPath = requestUri.getPath(); String ctxtPath = httpExchange.getHttpContext().getPath(); if (reqPath.length() > ctxtPath.length()) { return reqPath.substring(ctxtPath.length()); } return null; }
@Override @Property(MessageContext.PATH_INFO) public String getPathInfo() { URI requestUri = httpExchange.getRequestURI(); String reqPath = requestUri.getPath(); String ctxtPath = httpExchange.getHttpContext().getPath(); if (reqPath.length() > ctxtPath.length()) { return reqPath.substring(ctxtPath.length()); } return null; }
@Override @Property(MessageContext.PATH_INFO) public String getPathInfo() { URI requestUri = httpExchange.getRequestURI(); String reqPath = requestUri.getPath(); String ctxtPath = httpExchange.getHttpContext().getPath(); if (reqPath.length() > ctxtPath.length()) { return reqPath.substring(ctxtPath.length()); } return null; }
public static String fetchPathInfo(HttpExchange httpExchange) { String baseRequestPath = httpExchange.getHttpContext().getPath(); //TODO: Caution, getRequestURI does most likely also return the querystring. URI requestURI = httpExchange.getRequestURI(); String requestPath = requestURI.getPath(); int startOfPathInfo = requestPath.indexOf(baseRequestPath) + baseRequestPath.length(); return requestPath.substring(startOfPathInfo); }
ResteasyContext.pushContext(HttpContext.class, httpExchange.getHttpContext()); dispatcher.invoke(request, response); if (!response.isCommitted())
@Override public String getScheme() { String scheme = delegate.getRequestURI().getScheme(); if (scheme == null) { //fallback for relative urls (e.g. "/foo/bar?wsdl") with no scheme provided by the container HttpServer server = delegate.getHttpContext().getServer(); scheme = server instanceof HttpsServer ? "https" : "http"; } return scheme; }
public static final void redirectPermanently( final HttpExchange exchange, final URI uri, final String path ) throws IOException { try { final URI newUri = new URI( uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), exchange.getHttpContext().getPath() + path, uri.getQuery(), uri.getFragment() ); redirect( exchange, HttpResponseCode.REDIRECT_MOVED_PERMANENTLY, newUri.toString() ); } catch( URISyntaxException use ) { throw new IOException( use ); } }
public static final void redirect( final HttpExchange exchange, final URI uri, final String path ) throws IOException { try { final URI newUri = new URI( uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), exchange.getHttpContext().getPath() + path, uri.getQuery(), uri.getFragment() ); redirect( exchange, HttpResponseCode.REDIRECT_FOUND, newUri.toString() ); } catch( URISyntaxException use ) { throw new IOException( use ); } }
@Override public void processGet( final HttpExchange exchange ) throws IOException { // Get the file path , minus the context path final String fullPath = exchange.getRequestURI().getPath(); final String path = fullPath.substring( exchange.getHttpContext().getPath().length() ); try { final URL url = getClass().getResource( basePackage + path ); sendFile( exchange, url ); } catch( IOException ioe ) { throw ioe; } catch( Exception ex ) { RequestUtils.sendResponse( exchange, 500, "%s is forbidden", path ); } }
@Override public HttpContext getHttpContext() { if (contextDelegate == null) { contextDelegate = new HttpContextDelegate(delegate.getHttpContext(), PathUtils.getPath(delegate.getRequestURI())); } return contextDelegate; }
fullPath.substring( exchange.getHttpContext().getPath().length() );
String decodedBasePath = exchange.getHttpContext().getPath();
public Result authenticate (HttpExchange t) HttpContext context = t.getHttpContext(); Headers rmap = (Headers) t.getRequestHeaders();
getLog().info( "%s: %s %s", exchange.getHttpContext().getPath(), method, exchange.getRequestURI() );
String decodedBasePath = exchange.getHttpContext().getPath();