~tritone-team/tritone/eucalyptus

« back to all changes in this revision

Viewing changes to clc/modules/wsstack/src/main/java/com/eucalyptus/ws/util/HttpUtils.java

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-12-01 21:09:28 UTC
  • mto: This revision was merged to the branch mainline in revision 75.
  • Revision ID: james.westby@ubuntu.com-20091201210928-o2dvg0ubljhb0ft6
Tags: upstream-1.6.1~bzr1083
ImportĀ upstreamĀ versionĀ 1.6.1~bzr1083

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
 */
64
64
package com.eucalyptus.ws.util;
65
65
 
 
66
import java.util.List;
 
67
 
66
68
import org.jboss.netty.buffer.ChannelBuffer;
67
69
import org.jboss.netty.handler.codec.frame.TooLongFrameException;
 
70
import org.jboss.netty.handler.codec.http.HttpMethod;
68
71
 
69
72
import com.eucalyptus.ws.HttpException;
 
73
import com.google.common.collect.Lists;
70
74
 
71
75
 
72
76
public class HttpUtils {
88
92
      }
89
93
    }
90
94
  }
 
95
  private static List<String> httpVerbPrefix = Lists.newArrayList( HttpMethod.CONNECT.getName( ).substring( 0, 3 ),
 
96
                                                                   HttpMethod.GET.getName( ).substring( 0, 3 ),
 
97
                                                                   HttpMethod.PUT.getName( ).substring( 0, 3 ),
 
98
                                                                   HttpMethod.POST.getName( ).substring( 0, 3 ),
 
99
                                                                   HttpMethod.HEAD.getName( ).substring( 0, 3 ),
 
100
                                                                   HttpMethod.OPTIONS.getName( ).substring( 0, 3 ),
 
101
                                                                   HttpMethod.TRACE.getName( ).substring( 0, 3 ) );
 
102
                                                                   
 
103
                                                                   
 
104
  public static boolean maybeSsl( ChannelBuffer buffer ) throws HttpException {
 
105
    buffer.markReaderIndex( );
 
106
    StringBuffer sb = new StringBuffer( );
 
107
    for( int lineLength = 0; lineLength++ < 3; sb.append( (char) buffer.readByte() ) );
 
108
    buffer.resetReaderIndex( );
 
109
    return !httpVerbPrefix.contains( sb.toString( ) );
 
110
  }
91
111
 
 
112
  
92
113
  public static final byte SP = 32;
93
114
  public static final byte HT = 9;
94
115
  public static final byte CR = 13;