コード例 #1
0
 private RequestAttributes getRequestAttributes() {
   RequestAttributes attributes = request.get(RequestAttributes.class);
   if (attributes == null) {
     attributes = new RequestAttributes();
     request.add(attributes);
   }
   return attributes;
 }
コード例 #2
0
  private String generateRedirectLocation(Context context, Request request, String path) {
    // Rules
    // 1. Given absolute URL use it
    // 2. Given Starting Slash prepend public facing domain:port if provided if not use base URL of
    // request
    // 3. Given relative URL prepend public facing domain:port plus parent path of request URL
    // otherwise full parent path

    PublicAddress publicAddress = context.get(PublicAddress.class);
    String generatedPath;
    URI host = publicAddress.getAddress(context);

    if (ABSOLUTE_PATTERN.matcher(path).matches()) {
      // Rule 1 - Path is absolute
      generatedPath = path;
    } else {
      if (path.charAt(0) == '/') {
        // Rule 2 - Starting Slash
        generatedPath = host.toString() + path;
      } else {
        // Rule 3
        generatedPath = host.toString() + getParentPath(request.getUri()) + path;
      }
    }

    return generatedPath;
  }
コード例 #3
0
 @Override
 public Collection<Cookie> getRequestCookies() {
   final List<Cookie> newCookies = new ArrayList<>();
   final Set<io.netty.handler.codec.http.cookie.Cookie> cookies = request.getCookies();
   for (final io.netty.handler.codec.http.cookie.Cookie cookie : cookies) {
     final Cookie newCookie = new Cookie(cookie.name(), cookie.value());
     newCookie.setDomain(cookie.domain());
     newCookie.setPath(cookie.path());
     newCookie.setMaxAge((int) cookie.maxAge());
     newCookie.setSecure(cookie.isSecure());
     newCookie.setHttpOnly(cookie.isHttpOnly());
     newCookies.add(newCookie);
   }
   return newCookies;
 }
コード例 #4
0
 @Override
 public String getRequestHeader(String name) {
   return request.getHeaders().get(name);
 }
コード例 #5
0
 @Override
 public Map<String, String[]> getRequestParameters() {
   return flattenMap(combineMaps(request.getQueryParams(), form));
 }
コード例 #6
0
 @Override
 public String getRequestParameter(String name) {
   return Optional.ofNullable(request.getQueryParams().get(name)).orElseGet(() -> form.get(name));
 }
コード例 #7
0
 private static boolean isFormAvailable(Request request, TypedData body) {
   HttpMethod method = request.getMethod();
   return body.getContentType().isForm() && (method.isPost() || method.isPut());
 }
コード例 #8
0
 @Override
 public String getPath() {
   return request.getPath();
 }
コード例 #9
0
 @Override
 public String getFullRequestURL() {
   return getAddress().toString() + request.getUri();
 }
コード例 #10
0
 @Override
 public String getRemoteAddr() {
   return request.getRemoteAddress().getHostText();
 }
コード例 #11
0
 @Override
 public String getRequestMethod() {
   return request.getMethod().getName();
 }