Refine search
uriBuilder.append(this.uriPath); if (this.uri.getRawQuery() != null) { uriBuilder.append('?').append(this.uri.getRawQuery()); if (this.uri.getRawFragment() != null) { uriBuilder.append('#').append(this.uri.getRawFragment());
protected URIBuilder setQueryNVP(List<NameValuePair> nvp) throws URISyntaxException { /* Passing the query string in the URI constructor will * double-escape query parameters and goober things up. So we have * to create a full path+query+fragment and use URI#resolve() to * create the new URI. */ StringBuilder sb = new StringBuilder(); String path = base.getRawPath(); if (path != null) sb.append(path); sb.append('?'); sb.append(format(nvp, isUrlEncodingEnabled, enc)); String frag = base.getRawFragment(); if (frag != null) sb.append('#').append(frag); this.base = base.resolve(sb.toString()); return this; }
this.port = String.valueOf(uri.getPort()); if (StringUtils.hasLength(uri.getRawPath())) { this.pathBuilder = new CompositePathComponentBuilder(); this.pathBuilder.addPath(uri.getRawPath()); if (StringUtils.hasLength(uri.getRawQuery())) { this.queryParams.clear(); query(uri.getRawQuery()); if (uri.getRawFragment() != null) { this.fragment = uri.getRawFragment();
@Override public WebSocketStream websocketStreamAbs(String url, MultiMap headers, WebsocketVersion version, String subProtocols) { URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } String scheme = uri.getScheme(); if (!"ws".equals(scheme) && !"wss".equals(scheme)) { throw new IllegalArgumentException("Scheme: " + scheme); } boolean ssl = scheme.length() == 3; int port = uri.getPort(); if (port == -1) port = ssl ? 443 : 80; StringBuilder relativeUri = new StringBuilder(); if (uri.getRawPath() != null) { relativeUri.append(uri.getRawPath()); } if (uri.getRawQuery() != null) { relativeUri.append('?').append(uri.getRawQuery()); } if (uri.getRawFragment() != null) { relativeUri.append('#').append(uri.getRawFragment()); } RequestOptions options = new RequestOptions().setHost(uri.getHost()).setPort(port).setSsl(ssl).setURI(relativeUri.toString()); return websocketStream(options, headers, version, subProtocols); }
/** * Constructor to create from a URI. * @param uri The URI */ @SuppressWarnings("unchecked") DefaultUriBuilder(URI uri) { this.scheme = uri.getScheme(); this.userInfo = uri.getRawUserInfo(); this.authority = uri.getRawAuthority(); this.host = uri.getHost(); this.port = uri.getPort(); this.path = new StringBuilder(); final String rawPath = uri.getRawPath(); if (rawPath != null) { this.path.append(rawPath); } this.fragment = uri.getRawFragment(); final String query = uri.getQuery(); if (query != null) { final Map parameters = new QueryStringDecoder(uri).parameters(); this.queryParams = new MutableConvertibleMultiValuesMap<String>(parameters); } else { this.queryParams = new MutableConvertibleMultiValuesMap<>(); } }
uriBuilder.append(this.uriPath); if (this.uri.getRawQuery() != null) { uriBuilder.append('?').append(this.uri.getRawQuery()); if (this.uri.getRawFragment() != null) { uriBuilder.append('#').append(this.uri.getRawFragment());
private static void checkURI(URI uri) { if (!uri.isAbsolute()) { throw new IllegalArgumentException("URI is not absolute: " + uri); } else if (!uri.getRawSchemeSpecificPart().startsWith("/")) { throw new IllegalArgumentException("URI is not hierarchical: " + uri); } if (!"file".equals(uri.getScheme())) { throw new IllegalArgumentException("Expected file scheme in URI: " + uri); } String rawPath = uri.getRawPath(); if (rawPath == null || rawPath.isEmpty()) { throw new IllegalArgumentException("Expected non-empty path in URI: " + uri); } if (uri.getRawAuthority() != null) { throw new IllegalArgumentException("Found authority in URI: " + uri); } if (uri.getRawQuery() != null) { throw new IllegalArgumentException("Found query in URI: " + uri); } if (uri.getRawFragment() != null) { throw new IllegalArgumentException("Found fragment in URI: " + uri); } }
protected URIBuilder setQueryNVP(List<NameValuePair> nvp) throws URISyntaxException { /* Passing the query string in the URI constructor will * double-escape query parameters and goober things up. So we have * to create a full path+query+fragment and use URI#resolve() to * create the new URI. */ StringBuilder sb = new StringBuilder(); String path = base.getRawPath(); if (path != null) sb.append(path); sb.append('?'); sb.append(format(nvp, isUrlEncodingEnabled, enc)); String frag = base.getRawFragment(); if (frag != null) sb.append('#').append(frag); this.base = base.resolve(sb.toString()); return this; }
private void sendLogin(HttpServerRequest request, HttpServerResponse response) throws HttpAuthenticationException { // Save the current request. URI requestURI = request.getRequestURI(); HttpScope session = getSessionScope(request, true); if (session != null && session.supportsAttachments()) { StringBuilder sb = new StringBuilder(); String scheme = requestURI.getScheme(); sb.append(scheme); sb.append("://"); sb.append(requestURI.getHost()); int port = requestURI.getPort(); if (appendPort(scheme, port)) { sb.append(':').append(port); } sb.append(requestURI.getPath()); if(requestURI.getRawQuery() != null) { sb.append("?"); sb.append(requestURI.getRawQuery()); } if(requestURI.getRawFragment() != null) { sb.append("#"); sb.append(requestURI.getRawFragment()); } //TODO: we need to have some way up updating the jsessionid path parameter if the session ID changes //see UNDERTOW-958 for more details session.setAttachment(LOCATION_KEY, sb.toString()); request.suspendRequest(); } sendPage(loginPage, request, response); }
/** * Generate a HTTP/2 {code :path} from a URI in accordance with * <a href="https://tools.ietf.org/html/rfc7230#section-5.3">rfc7230, 5.3</a>. */ private static AsciiString toHttp2Path(URI uri) { StringBuilder pathBuilder = new StringBuilder(length(uri.getRawPath()) + length(uri.getRawQuery()) + length(uri.getRawFragment()) + 2); if (!isNullOrEmpty(uri.getRawPath())) { pathBuilder.append(uri.getRawPath()); } if (!isNullOrEmpty(uri.getRawQuery())) { pathBuilder.append('?'); pathBuilder.append(uri.getRawQuery()); } if (!isNullOrEmpty(uri.getRawFragment())) { pathBuilder.append('#'); pathBuilder.append(uri.getRawFragment()); } String path = pathBuilder.toString(); return path.isEmpty() ? EMPTY_REQUEST_PATH : new AsciiString(path); }
/** * Set the raw, already-escaped query string. No additional escaping will * be done on the string. * @param query * @return */ public URIBuilder setRawQuery( String query ) throws URISyntaxException { this.base = update( base.getScheme(), base.getUserInfo(), base.getHost(), base.getPort(), base.getRawPath(), query, base.getRawFragment() ); return this; }
/** * Determines if a given URI is plain, i.e. it does not contain a query or a fragment. * @param uri The URI to check to for plainness. * @throws NullPointerException if the given URI is <code>null</code>. * @return <code>true</code> if the URI has no query or fragment. */ public static boolean isPlainURI(final URI uri) { requireNonNull(uri, "URI cannot be null"); return uri.getRawQuery() == null && uri.getRawFragment() == null; //see if there is no query and no fragment }
private void checkURI(URI uri) { if (!uri.isAbsolute()) { throw new IllegalArgumentException(); } else if (!uri.getRawSchemeSpecificPart().startsWith("/")) { throw new IllegalArgumentException(); } String temp = uri.getScheme(); if (temp == null || !temp.equals("file")) { throw new IllegalArgumentException(); } temp = uri.getRawPath(); if (temp == null || temp.length() == 0) { throw new IllegalArgumentException(); } if (uri.getRawAuthority() != null) { throw new IllegalArgumentException(); } if (uri.getRawQuery() != null) { throw new IllegalArgumentException(); } if (uri.getRawFragment() != null) { throw new IllegalArgumentException(); } }
/** * Set the raw, already-escaped query string. No additional escaping will * be done on the string. * @param query * @return */ public URIBuilder setRawQuery( String query ) throws URISyntaxException { this.base = update( base.getScheme(), base.getUserInfo(), base.getHost(), base.getPort(), base.getRawPath(), query, base.getRawFragment() ); return this; }
/** * The Google Cloud Pub/Sub API URI. By default, this is the Google Cloud Pub/Sub provider, however you may run a * local Developer Server. * * @param uri the service to connect to. */ public Builder uri(final URI uri) { checkNotNull(uri, "uri"); checkArgument(uri.getRawQuery() == null, "illegal service uri: %s", uri); checkArgument(uri.getRawFragment() == null, "illegal service uri: %s", uri); this.uri = uri; return this; } }
/** * Generate a HTTP/2 {code :path} from a URI in accordance with * <a href="https://tools.ietf.org/html/rfc7230#section-5.3">rfc7230, 5.3</a>. */ private static String toHttp2Path(URI uri) { final StringBuilder pathBuilder = new StringBuilder( length(uri.getRawPath()) + length(uri.getRawQuery()) + length(uri.getRawFragment()) + 2); if (!isNullOrEmpty(uri.getRawPath())) { pathBuilder.append(uri.getRawPath()); } if (!isNullOrEmpty(uri.getRawQuery())) { pathBuilder.append('?'); pathBuilder.append(uri.getRawQuery()); } if (!isNullOrEmpty(uri.getRawFragment())) { pathBuilder.append('#'); pathBuilder.append(uri.getRawFragment()); } return pathBuilder.length() != 0 ? pathBuilder.toString() : EMPTY_REQUEST_PATH; }
protected URIBuilder setQueryNVP( List<NameValuePair> nvp ) throws URISyntaxException { /* Passing the query string in the URI constructor will * double-escape query parameters and goober things up. So we have * to create a full path+query+fragment and use URI#resolve() to * create the new URI. */ StringBuilder sb = new StringBuilder(); String path = base.getRawPath(); if ( path != null ) sb.append( path ); sb.append( '?' ); sb.append( URLEncodedUtils.format( nvp, ENC ) ); String frag = base.getRawFragment(); if ( frag != null ) sb.append( '#' ).append( frag ); this.base = base.resolve( sb.toString() ); return this; }
public static URI replacePath(URI uri, String path) throws URISyntaxException { return buildUri(uri.getScheme(), uri.getHost(), uri.getPort(), path, uri.getRawQuery(), uri.getRawFragment()); } private static DateFormat getHeaderFormat() {
target.getHostName(), target.getPort(), uri.getRawPath(), uri.getRawQuery(), dropFragment ? null : uri.getRawFragment()); } else { return URIUtils.createURI( null, -1, uri.getRawPath(), uri.getRawQuery(), dropFragment ? null : uri.getRawFragment());
protected URIBuilder setQueryNVP( List<NameValuePair> nvp ) throws URISyntaxException { /* Passing the query string in the URI constructor will * double-escape query parameters and goober things up. So we have * to create a full path+query+fragment and use URI#resolve() to * create the new URI. */ StringBuilder sb = new StringBuilder(); String path = base.getRawPath(); if ( path != null ) sb.append( path ); sb.append( '?' ); sb.append( URLEncodedUtils.format( nvp, ENC ) ); String frag = base.getRawFragment(); if ( frag != null ) sb.append( '#' ).append( frag ); this.base = base.resolve( sb.toString() ); return this; }