abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
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 04:21:57 GMT
I dunno, should we? :-)

Elias Torres wrote:
> Should we allow to override GET? :-)
> 
> =Elias
> 
> On 7/18/06, jmsnell@apache.org <jmsnell@apache.org> wrote:
>> Author: jmsnell
>> Date: Tue Jul 18 17:36:53 2006
>> New Revision: 423311
>>
>> URL: http://svn.apache.org/viewvc?rev=423311&view=rev
>> Log:
>> Google's gdata api supports the notion of tunnelling PUT and DELETE
>> requests via POST using
>> a X-Method-Override request header in order to deal with scenarios in
>> which PUT and DELETE
>> are being blocked at the firewall.
>>
>> This change moves support for the X-Method-Override header into the
>> ServletRequestContext
>> implementation so that implementations can optionally use the mechanism.
>>
>> This is a work in progress.
>>
>> Modified:
>>    
>> incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
>>
>>
>> Modified:
>> incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
>>
>> URL:
>> http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java?rev=423311&r1=423310&r2=423311&view=diff
>>
>> ==============================================================================
>>
>> ---
>> incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/server/servlet/ServletRequestContext.java
>> (original)
>> +++
>> 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());
>>    }
>>
>>
>>
> 

Mime
View raw message