View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4   //  ------------------------------------------------------------------------
5   //  All rights reserved. This program and the accompanying materials
6   //  are made available under the terms of the Eclipse Public License v1.0
7   //  and Apache License v2.0 which accompanies this distribution.
8   //
9   //      The Eclipse Public License is available at
10  //      http://www.eclipse.org/legal/epl-v10.html
11  //
12  //      The Apache License v2.0 is available at
13  //      http://www.opensource.org/licenses/apache2.0.php
14  //
15  //  You may elect to redistribute this code under either of these licenses.
16  //  ========================================================================
17  //
18  
19  package org.eclipse.jetty.fcgi;
20  
21  public class FCGI
22  {
23      private FCGI()
24      {
25      }
26  
27      public enum Role
28      {
29          RESPONDER(1), AUTHORIZER(2), FILTER(3);
30  
31          public static Role from(int code)
32          {
33              switch (code)
34              {
35                  case 1:
36                      return RESPONDER;
37                  case 2:
38                      return AUTHORIZER;
39                  case 3:
40                      return FILTER;
41                  default:
42                      throw new IllegalArgumentException();
43              }
44          }
45  
46          public final int code;
47  
48          private Role(int code)
49          {
50              this.code = code;
51          }
52      }
53  
54      public enum FrameType
55      {
56          BEGIN_REQUEST(1),
57          ABORT_REQUEST(2),
58          END_REQUEST(3),
59          PARAMS(4),
60          STDIN(5),
61          STDOUT(6),
62          STDERR(7),
63          DATA(8),
64          GET_VALUES(9),
65          GET_VALUES_RESULT(10);
66  
67          public static FrameType from(int code)
68          {
69              switch (code)
70              {
71                  case 1:
72                      return BEGIN_REQUEST;
73                  case 2:
74                      return ABORT_REQUEST;
75                  case 3:
76                      return END_REQUEST;
77                  case 4:
78                      return PARAMS;
79                  case 5:
80                      return STDIN;
81                  case 6:
82                      return STDOUT;
83                  case 7:
84                      return STDERR;
85                  case 8:
86                      return DATA;
87                  case 9:
88                      return GET_VALUES;
89                  case 10:
90                      return GET_VALUES_RESULT;
91                  default:
92                      throw new IllegalArgumentException();
93              }
94          }
95  
96          public final int code;
97  
98          private FrameType(int code)
99          {
100             this.code = code;
101         }
102     }
103 
104     public enum StreamType
105     {
106         STD_IN, STD_OUT, STD_ERR
107     }
108 
109     public static class Headers
110     {
111         public static final String AUTH_TYPE = "AUTH_TYPE";
112         public static final String CONTENT_LENGTH = "CONTENT_LENGTH";
113         public static final String CONTENT_TYPE = "CONTENT_TYPE";
114         public static final String DOCUMENT_ROOT = "DOCUMENT_ROOT";
115         public static final String DOCUMENT_URI = "DOCUMENT_URI";
116         public static final String GATEWAY_INTERFACE = "GATEWAY_INTERFACE";
117         public static final String HTTPS = "HTTPS";
118         public static final String PATH_INFO = "PATH_INFO";
119         public static final String QUERY_STRING = "QUERY_STRING";
120         public static final String REMOTE_ADDR = "REMOTE_ADDR";
121         public static final String REMOTE_PORT = "REMOTE_PORT";
122         public static final String REQUEST_METHOD = "REQUEST_METHOD";
123         public static final String REQUEST_URI = "REQUEST_URI";
124         public static final String SCRIPT_FILENAME = "SCRIPT_FILENAME";
125         public static final String SCRIPT_NAME = "SCRIPT_NAME";
126         public static final String SERVER_ADDR = "SERVER_ADDR";
127         public static final String SERVER_NAME = "SERVER_NAME";
128         public static final String SERVER_PORT = "SERVER_PORT";
129         public static final String SERVER_PROTOCOL = "SERVER_PROTOCOL";
130         public static final String SERVER_SOFTWARE = "SERVER_SOFTWARE";
131 
132         private Headers()
133         {
134         }
135     }
136 }