abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garrett Rooney" <roo...@electricjellyfish.net>
Subject Re: svn commit: r423311 - /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
Date Wed, 19 Jul 2006 00:50:47 GMT
On 7/18/06, jmsnell@apache.org <jmsnell@apache.org> wrote:

> +++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
Tue Jul 18 17:36:53 2006
> @@ -21,7 +21,6 @@
>  import java.io.InputStream;
>  import java.net.URI;
>  import java.net.URISyntaxException;
> -import java.util.ArrayList;
>  import java.util.Arrays;
>  import java.util.Collections;
>  import java.util.List;
> @@ -33,14 +32,35 @@
>  public class ServletRequestContext
>    implements RequestContext {
>
> +  public static final String X_OVERRIDE_HEADER = "X-Method-Override";
> +
>    private HttpServletRequest servletRequest = null;
> +  private boolean use_post_tunnel = true;
> +  private String method = null;
> +
> +  public ServletRequestContext(
> +    HttpServletRequest request) {
> +      this.servletRequest = request;
> +  }
>
> -  public ServletRequestContext(HttpServletRequest request) {
> -    this.servletRequest = request;
> +  public ServletRequestContext(
> +    HttpServletRequest request,
> +    boolean use_post_tunnel) {
> +      this(request);
> +      this.use_post_tunnel = use_post_tunnel;
>    }
>
>    public String getMethod() {
> -    return servletRequest.getMethod();
> +    if (method == null) {
> +      method = servletRequest.getMethod();
> +      if (use_post_tunnel && method.equalsIgnoreCase("POST")) {
> +        String override = servletRequest.getHeader(X_OVERRIDE_HEADER);
> +        if(override != null) {
> +          method = override.toUpperCase();
> +        }
> +      }
> +    }
> +    return method;
>    }
>
>    public URI getRequestUri() {
> @@ -79,10 +99,12 @@
>           return servletRequest.getHeader(name);
>    }
>
> +  @SuppressWarnings("unchecked")
>    public List<String> getHeaders(String name) {
>           return Collections.list(servletRequest.getHeaders(name));
>    }
>
> +  @SuppressWarnings("unchecked")
>    public List<String> getHeaderNames() {
>           return Collections.list(servletRequest.getHeaderNames());
>    }
> @@ -107,6 +129,7 @@
>           return Arrays.asList(servletRequest.getParameterValues(name));
>    }
>
> +  @SuppressWarnings("unchecked")
>    public List<String> getParameterNames() {
>           return Collections.list(servletRequest.getParameterNames());
>    }

Can we pick an indentation level for this file?  The new code is two
space indented like the rest of the tree, the existing code is clearly
not...

-garrett

Mime
View raw message