public static ResteasyUriInfo extractUriInfo(HttpServletRequest request, String servletPrefix) { String contextPath = request.getContextPath(); if (servletPrefix != null && servletPrefix.length() > 0 && !servletPrefix.equals("/")) { if (!contextPath.endsWith("/") && !servletPrefix.startsWith("/")) contextPath += "/"; contextPath += servletPrefix; } return new ResteasyUriInfo(request.getRequestURL(), request.getQueryString(), contextPath); }
public String getPath(boolean decode) { if (decode) return getPath(); return encodedPath; }
public void clearQueryParameters(boolean decode) { if (decode) clearQueryParameters(); else clearEncodedQueryParameters(); }
public void setUri(URI base, URI relative) { clearQueryParameters(true); clearQueryParameters(false); URI rel = base.resolve(relative); String absoluteUri = UriBuilder.fromUri(rel).replaceQuery(null).toTemplate(); initialize(absoluteUri, rel.getRawQuery(), base.getRawPath()); }
protected void processPath() { PathSegmentImpl.SegmentParse parse = PathSegmentImpl.parseSegmentsOptimization(encodedPath, false); encodedPathSegments = parse.segments; this.pathSegments = new ArrayList<PathSegment>(encodedPathSegments.size()); for (PathSegment segment : encodedPathSegments) { pathSegments.add(new PathSegmentImpl(((PathSegmentImpl) segment).getOriginal(), true)); } extractParameters(requestURI.getRawQuery()); if (parse.hasMatrixParams) extractMatchingPath(encodedPathSegments); else { matchingPath = encodedPath; if (matchingPath.length() > 1 && matchingPath.endsWith("/")) { matchingPath = matchingPath.substring(0, matchingPath.length() - 1); } } }
if (encode) list = uriInfo.getEncodedPathParameterPathSegments().get(paramName); list = uriInfo.getPathParameterPathSegments().get(paramName); throw new InternalServerErrorException(Messages.MESSAGES.unknownPathParam(paramName, uriInfo.getPath()));
uriInfo.addEncodedPathParameter(group.name, value); int index = matcher.start(group.group); encodedSegments[i] = request.getUri().getPathSegments(false).get(segmentIndex + i); uriInfo.getEncodedPathParameterPathSegments().add(group.name, encodedSegments); uriInfo.getPathParameterPathSegments().add(group.name, decodedSegments);
if (encode) list = uriInfo.getEncodedPathParameterPathSegments().get(paramName); list = uriInfo.getPathParameterPathSegments().get(paramName); throw new InternalServerErrorException(Messages.MESSAGES.unknownPathParam(paramName, uriInfo.getPath()));
uriInfo.addEncodedPathParameter(group.name, value); int index = matcher.start(group.group); encodedSegments[i] = request.getUri().getPathSegments(false).get(segmentIndex + i); uriInfo.getEncodedPathParameterPathSegments().add(group.name, encodedSegments); uriInfo.getPathParameterPathSegments().add(group.name, decodedSegments);
public void setUri(URI base, URI relative) { clearQueryParameters(true); clearQueryParameters(false); URI rel = base.resolve(relative); String absoluteUri = UriBuilder.fromUri(rel).replaceQuery(null).toTemplate(); initialize(absoluteUri, rel.getRawQuery(), base.getRawPath()); }
protected void processPath() { PathSegmentImpl.SegmentParse parse = PathSegmentImpl.parseSegmentsOptimization(encodedPath, false); encodedPathSegments = parse.segments; this.pathSegments = new ArrayList<PathSegment>(encodedPathSegments.size()); for (PathSegment segment : encodedPathSegments) { pathSegments.add(new PathSegmentImpl(((PathSegmentImpl) segment).getOriginal(), true)); } extractParameters(requestURI.getRawQuery()); if (parse.hasMatrixParams) extractMatchingPath(encodedPathSegments); else { matchingPath = encodedPath; if (matchingPath.length() > 1 && matchingPath.endsWith("/")) { matchingPath = matchingPath.substring(0, matchingPath.length() - 1); } } }
public static ResteasyUriInfo extractUriInfo(HttpRequest request, String contextPath, String protocol) { String host = request.headers().get(HttpHeaderNames.HOST, "unknown"); String uri = request.uri(); String uriString; // If we appear to have an absolute URL, don't try to recreate it from the host and request line. if (uri.startsWith(protocol + "://")) { uriString = uri; } else { uriString = protocol + "://" + host + uri; } URI absoluteURI = URI.create(uriString); return new ResteasyUriInfo(uriString, absoluteURI.getRawQuery(), contextPath); }
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 clearQueryParameters(boolean decode) { if (decode) clearQueryParameters(); else clearEncodedQueryParameters(); }
public static ResteasyUriInfo extractUriInfo(HttpRequest request, String contextPath, String protocol) { String host = HttpHeaders.getHost(request, "unknown"); String uri = request.getUri(); String uriString = protocol + "://" + host + uri; URI absoluteURI = URI.create(uriString); return new ResteasyUriInfo(uriString, absoluteURI.getRawQuery(), contextPath); }
public String getPath(boolean decode) { if (decode) return getPath(); return encodedPath; }
private static MockHttpRequest initWithUri(URI absoluteUri, URI baseUri) { if (baseUri == null) baseUri = EMPTY_URI; MockHttpRequest request = new MockHttpRequest(); request.httpHeaders = new ResteasyHttpHeaders(new CaseInsensitiveMap<String>()); //request.uri = new UriInfoImpl(absoluteUri, absoluteUri, absoluteUri.getPath(), absoluteUri.getQuery(), PathSegmentImpl.parseSegments(absoluteUri.getPath())); // remove query part URI absolutePath = UriBuilder.fromUri(absoluteUri).replaceQuery(null).build(); // path must be relative to the application's base uri URI relativeUri = baseUri.relativize(absoluteUri); relativeUri = UriBuilder.fromUri(relativeUri.getRawPath()).replaceQuery(absoluteUri.getRawQuery()).build(); request.uri = new ResteasyUriInfo(absoluteUri.toString(), absoluteUri.getRawQuery(), baseUri.getRawPath()); return request; }
public static ResteasyUriInfo extractUriInfo(HttpServerRequest req, String contextPath) { String host = req.host(); if (host == null) { host = "unknown"; } String uri = req.absoluteURI(); String protocol = req.scheme(); String uriString; // If we appear to have an absolute URL, don't try to recreate it from the host and request line. if (uri.startsWith(protocol + "://")) { uriString = uri; } else { uriString = protocol + "://" + host + uri; } URI absoluteURI = URI.create(uriString); return new ResteasyUriInfo(uriString, absoluteURI.getRawQuery(), contextPath); }
ResteasyUriInfo uriInfo = new ResteasyUriInfo(baseURI, relativeURI); return uriInfo;
public static ResteasyUriInfo extractUriInfo(HttpServletRequest request, String servletPrefix) { String contextPath = request.getContextPath(); if (servletPrefix != null && servletPrefix.length() > 0 && !servletPrefix.equals("/")) { if (!contextPath.endsWith("/") && !servletPrefix.startsWith("/")) contextPath += "/"; contextPath += servletPrefix; } return new ResteasyUriInfo(request.getRequestURL(), request.getQueryString(), contextPath); }