test_class.declarator: factory
test_class.modifier: private static
test_class.original_string: private static HttpServletRequestImplFactory factory;
test_class.type: HttpServletRequestImplFactory
test_class.var_name: factory
test_class.declarator: socket
test_class.modifier: private static
test_class.original_string: private static Socket socket;
test_class.type: Socket
test_class.var_name: socket
test_class.declarator: cookieParser
test_class.modifier: private static
test_class.original_string: private static Parser<Map<String, Cookie>> cookieParser;
test_class.type: Parser<Map<String, Cookie>>
test_class.var_name: cookieParser
test_class.declarator: headersParser
test_class.modifier: private static
test_class.original_string: private static Parser<Headers> headersParser;
test_class.type: Parser<Headers>
test_class.var_name: headersParser
test_class.declarator: headers
test_class.modifier: private static
test_class.original_string: private static Headers headers;
test_class.type: Headers
test_class.var_name: headers
test_class.file: http/src/test/java/ro/polak/http/servlet/factory/HttpServletRequestImplFactoryTest.java
test_class.identifier: HttpServletRequestImplFactoryTest
test_case.body: @Test(expected = UnsupportedProtocolException.class)
      public void shouldThrowUnsuportedProtocolExceptionIllegalProtocol() throws Exception {
          when(socket.getInputStream())
                  .thenReturn(new ByteArrayInputStream("GET / MALF/1.0\r\nHeader1: someValue\r\n\r\n".getBytes()));
          factory.createFromSocket(socket);
      }
test_case.class_method_signature: HttpServletRequestImplFactoryTest.shouldThrowUnsuportedProtocolExceptionIllegalProtocol()
test_case.full_signature: @Test(expected = UnsupportedProtocolException.class) public void shouldThrowUnsuportedProtocolExceptionIllegalProtocol()
test_case.identifier: shouldThrowUnsuportedProtocolExceptionIllegalProtocol
test_case.invocations: thenReturn when getInputStream getBytes createFromSocket
test_case.modifiers: @Test(expected = UnsupportedProtocolException.class) public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldThrowUnsuportedProtocolExceptionIllegalProtocol()
focal_class.declarator: DEFAULT_SCHEME = "http"
focal_class.modifier: private static final
focal_class.original_string: private static final String DEFAULT_SCHEME = "http";
focal_class.type: String
focal_class.var_name: DEFAULT_SCHEME
focal_class.declarator: MULTIPART_BUFFER_LENGTH = 2048
focal_class.modifier: private static final
focal_class.original_string: private static final int MULTIPART_BUFFER_LENGTH = 2048;
focal_class.type: int
focal_class.var_name: MULTIPART_BUFFER_LENGTH
focal_class.declarator: BOUNDARY_START = "boundary="
focal_class.modifier: private static final
focal_class.original_string: private static final String BOUNDARY_START = "boundary=";
focal_class.type: String
focal_class.var_name: BOUNDARY_START
focal_class.declarator: URI_MAX_LENGTH = 2048
focal_class.modifier: private static final
focal_class.original_string: private static final int URI_MAX_LENGTH = 2048;
focal_class.type: int
focal_class.var_name: URI_MAX_LENGTH
focal_class.declarator: POST_MAX_LENGTH = 50 * 1024 * 1024
focal_class.modifier: private static final
focal_class.original_string: private static final int POST_MAX_LENGTH = 50 * 1024 * 1024;
focal_class.type: int
focal_class.var_name: POST_MAX_LENGTH
focal_class.declarator: STATUS_MAX_LENGTH = 8 + URI_MAX_LENGTH + 9
focal_class.modifier: private static final
focal_class.original_string: private static final int STATUS_MAX_LENGTH = 8 + URI_MAX_LENGTH + 9;
focal_class.type: int
focal_class.var_name: STATUS_MAX_LENGTH
focal_class.declarator: RECOGNIZED_METHODS = {
              "OPTIONS",
              "GET",
              "HEAD",
              "POST",
              "PUT",
              "DELETE",
              "TRACE",
              "CONNECT"
      }
focal_class.modifier: private static final
focal_class.original_string: private static final String[] RECOGNIZED_METHODS = {
              "OPTIONS",
              "GET",
              "HEAD",
              "POST",
              "PUT",
              "DELETE",
              "TRACE",
              "CONNECT"
      };
focal_class.type: String[]
focal_class.var_name: RECOGNIZED_METHODS
focal_class.declarator: METHOD_MAX_LENGTH
focal_class.modifier: private static final
focal_class.original_string: private static final int METHOD_MAX_LENGTH;
focal_class.type: int
focal_class.var_name: METHOD_MAX_LENGTH
focal_class.declarator: RECOGNIZED_METHODS_LIST = Arrays.asList(RECOGNIZED_METHODS)
focal_class.modifier: private static final
focal_class.original_string: private static final List<String> RECOGNIZED_METHODS_LIST = Arrays.asList(RECOGNIZED_METHODS);
focal_class.type: List<String>
focal_class.var_name: RECOGNIZED_METHODS_LIST
focal_class.declarator: HEADERS_END_DELIMINATOR = "\n\r\n"
focal_class.modifier: private static final
focal_class.original_string: private static final String HEADERS_END_DELIMINATOR = "\n\r\n";
focal_class.type: String
focal_class.var_name: HEADERS_END_DELIMINATOR
focal_class.declarator: MINUMUM_HEADER_LINE_LENGTH = 3
focal_class.modifier: private static final
focal_class.original_string: private static final int MINUMUM_HEADER_LINE_LENGTH = 3;
focal_class.type: int
focal_class.var_name: MINUMUM_HEADER_LINE_LENGTH
focal_class.declarator: MULTIPART_FORM_DATA_HEADER_START = "multipart/form-data"
focal_class.modifier: private static final
focal_class.original_string: private static final String MULTIPART_FORM_DATA_HEADER_START = "multipart/form-data";
focal_class.type: String
focal_class.var_name: MULTIPART_FORM_DATA_HEADER_START
focal_class.declarator: DEFAULT_SERVLET_CONTEXT_PATH = "/"
focal_class.modifier: private static final
focal_class.original_string: private static final String DEFAULT_SERVLET_CONTEXT_PATH = "/";
focal_class.type: String
focal_class.var_name: DEFAULT_SERVLET_CONTEXT_PATH
focal_class.declarator: NEWLINE = '\n'
focal_class.modifier: private static final
focal_class.original_string: private static final char NEWLINE = '\n';
focal_class.type: char
focal_class.var_name: NEWLINE
focal_class.declarator: HTTP_1_0 = "HTTP/1.0"
focal_class.modifier: private static final
focal_class.original_string: private static final String HTTP_1_0 = "HTTP/1.0";
focal_class.type: String
focal_class.var_name: HTTP_1_0
focal_class.declarator: HTTP_1_1 = "HTTP/1.1"
focal_class.modifier: private static final
focal_class.original_string: private static final String HTTP_1_1 = "HTTP/1.1";
focal_class.type: String
focal_class.var_name: HTTP_1_1
focal_class.declarator: headersParser
focal_class.modifier: private final
focal_class.original_string: private final Parser<Headers> headersParser;
focal_class.type: Parser<Headers>
focal_class.var_name: headersParser
focal_class.declarator: queryStringParser
focal_class.modifier: private final
focal_class.original_string: private final Parser<Map<String, String>> queryStringParser;
focal_class.type: Parser<Map<String, String>>
focal_class.var_name: queryStringParser
focal_class.declarator: statusParser
focal_class.modifier: private final
focal_class.original_string: private final Parser<RequestStatus> statusParser;
focal_class.type: Parser<RequestStatus>
focal_class.var_name: statusParser
focal_class.declarator: cookieParser
focal_class.modifier: private final
focal_class.original_string: private final Parser<Map<String, Cookie>> cookieParser;
focal_class.type: Parser<Map<String, Cookie>>
focal_class.var_name: cookieParser
focal_class.declarator: multipartHeadersPartParser
focal_class.modifier: private
focal_class.original_string: private Parser<MultipartHeadersPart> multipartHeadersPartParser;
focal_class.type: Parser<MultipartHeadersPart>
focal_class.var_name: multipartHeadersPartParser
focal_class.declarator: tempPath
focal_class.modifier: private final
focal_class.original_string: private final String tempPath;
focal_class.type: String
focal_class.var_name: tempPath
focal_class.file: http/src/main/java/ro/polak/http/servlet/factory/HttpServletRequestImplFactory.java
focal_class.identifier: HttpServletRequestImplFactory
focal_class.class_method_signature: HttpServletRequestImplFactory.HttpServletRequestImplFactory(final Parser<Headers> headersParser,
                                           final Parser<Map<String, String>> queryStringParser,
                                           final Parser<RequestStatus> statusParser,
                                           final Parser<Map<String, Cookie>> cookieParser,
                                           final Parser<MultipartHeadersPart> multipartHeadersPartParser,
                                           final String tempPath)
focal_class.full_signature: public  HttpServletRequestImplFactory(final Parser<Headers> headersParser,
                                           final Parser<Map<String, String>> queryStringParser,
                                           final Parser<RequestStatus> statusParser,
                                           final Parser<Map<String, Cookie>> cookieParser,
                                           final Parser<MultipartHeadersPart> multipartHeadersPartParser,
                                           final String tempPath)
focal_class.identifier: HttpServletRequestImplFactory
focal_class.modifiers: public
focal_class.parameters: (final Parser<Headers> headersParser,
                                           final Parser<Map<String, String>> queryStringParser,
                                           final Parser<RequestStatus> statusParser,
                                           final Parser<Map<String, Cookie>> cookieParser,
                                           final Parser<MultipartHeadersPart> multipartHeadersPartParser,
                                           final String tempPath)
focal_class.signature:  HttpServletRequestImplFactory(final Parser<Headers> headersParser,
                                           final Parser<Map<String, String>> queryStringParser,
                                           final Parser<RequestStatus> statusParser,
                                           final Parser<Map<String, Cookie>> cookieParser,
                                           final Parser<MultipartHeadersPart> multipartHeadersPartParser,
                                           final String tempPath)
focal_class.class_method_signature: HttpServletRequestImplFactory.createFromSocket(final Socket socket)
focal_class.full_signature: public HttpServletRequestImpl createFromSocket(final Socket socket)
focal_class.identifier: createFromSocket
focal_class.modifiers: public
focal_class.parameters: (final Socket socket)
focal_class.return: HttpServletRequestImpl
focal_class.signature: HttpServletRequestImpl createFromSocket(final Socket socket)
focal_class.class_method_signature: HttpServletRequestImplFactory.getImplicitServletContext()
focal_class.full_signature: private ServletContextImpl getImplicitServletContext()
focal_class.identifier: getImplicitServletContext
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: ServletContextImpl
focal_class.signature: ServletContextImpl getImplicitServletContext()
focal_class.class_method_signature: HttpServletRequestImplFactory.computeHeaders(final InputStream in)
focal_class.full_signature: private Headers computeHeaders(final InputStream in)
focal_class.identifier: computeHeaders
focal_class.modifiers: private
focal_class.parameters: (final InputStream in)
focal_class.return: Headers
focal_class.signature: Headers computeHeaders(final InputStream in)
focal_class.class_method_signature: HttpServletRequestImplFactory.isValidProtocol(final String protocol)
focal_class.full_signature: private boolean isValidProtocol(final String protocol)
focal_class.identifier: isValidProtocol
focal_class.modifiers: private
focal_class.parameters: (final String protocol)
focal_class.return: boolean
focal_class.signature: boolean isValidProtocol(final String protocol)
focal_class.class_method_signature: HttpServletRequestImplFactory.assignSocketMetadata(final Socket socket, final HttpServletRequestImpl.Builder builder)
focal_class.full_signature: private void assignSocketMetadata(final Socket socket, final HttpServletRequestImpl.Builder builder)
focal_class.identifier: assignSocketMetadata
focal_class.modifiers: private
focal_class.parameters: (final Socket socket, final HttpServletRequestImpl.Builder builder)
focal_class.return: void
focal_class.signature: void assignSocketMetadata(final Socket socket, final HttpServletRequestImpl.Builder builder)
focal_class.class_method_signature: HttpServletRequestImplFactory.getCookies(final Headers headers)
focal_class.full_signature: private Map<String, Cookie> getCookies(final Headers headers)
focal_class.identifier: getCookies
focal_class.modifiers: private
focal_class.parameters: (final Headers headers)
focal_class.return: Map<String, Cookie>
focal_class.signature: Map<String, Cookie> getCookies(final Headers headers)
focal_class.class_method_signature: HttpServletRequestImplFactory.getStatusLine(final InputStream in)
focal_class.full_signature: private String getStatusLine(final InputStream in)
focal_class.identifier: getStatusLine
focal_class.modifiers: private
focal_class.parameters: (final InputStream in)
focal_class.return: String
focal_class.signature: String getStatusLine(final InputStream in)
focal_class.class_method_signature: HttpServletRequestImplFactory.getHeadersString(final InputStream in)
focal_class.full_signature: private String getHeadersString(final InputStream in)
focal_class.identifier: getHeadersString
focal_class.modifiers: private
focal_class.parameters: (final InputStream in)
focal_class.return: String
focal_class.signature: String getHeadersString(final InputStream in)
focal_class.class_method_signature: HttpServletRequestImplFactory.getEndChars(final StringBuilder headersString, final int headersEndSymbolLength)
focal_class.full_signature: private String getEndChars(final StringBuilder headersString, final int headersEndSymbolLength)
focal_class.identifier: getEndChars
focal_class.modifiers: private
focal_class.parameters: (final StringBuilder headersString, final int headersEndSymbolLength)
focal_class.return: String
focal_class.signature: String getEndChars(final StringBuilder headersString, final int headersEndSymbolLength)
focal_class.class_method_signature: HttpServletRequestImplFactory.handlePostRequest(final HttpServletRequestImpl.Builder builder,
                                     final InputStream in,
                                     final Headers headers)
focal_class.full_signature: private void handlePostRequest(final HttpServletRequestImpl.Builder builder,
                                     final InputStream in,
                                     final Headers headers)
focal_class.identifier: handlePostRequest
focal_class.modifiers: private
focal_class.parameters: (final HttpServletRequestImpl.Builder builder,
                                     final InputStream in,
                                     final Headers headers)
focal_class.return: void
focal_class.signature: void handlePostRequest(final HttpServletRequestImpl.Builder builder,
                                     final InputStream in,
                                     final Headers headers)
focal_class.class_method_signature: HttpServletRequestImplFactory.isMultipartRequest(final Headers headers)
focal_class.full_signature: private boolean isMultipartRequest(final Headers headers)
focal_class.identifier: isMultipartRequest
focal_class.modifiers: private
focal_class.parameters: (final Headers headers)
focal_class.return: boolean
focal_class.signature: boolean isMultipartRequest(final Headers headers)
focal_class.class_method_signature: HttpServletRequestImplFactory.handlePostPlainRequest(final HttpServletRequestImpl.Builder builder,
                                          final InputStream in,
                                          final int postLength)
focal_class.full_signature: private void handlePostPlainRequest(final HttpServletRequestImpl.Builder builder,
                                          final InputStream in,
                                          final int postLength)
focal_class.identifier: handlePostPlainRequest
focal_class.modifiers: private
focal_class.parameters: (final HttpServletRequestImpl.Builder builder,
                                          final InputStream in,
                                          final int postLength)
focal_class.return: void
focal_class.signature: void handlePostPlainRequest(final HttpServletRequestImpl.Builder builder,
                                          final InputStream in,
                                          final int postLength)
focal_class.class_method_signature: HttpServletRequestImplFactory.handlePostMultipartRequest(final HttpServletRequestImpl.Builder builder,
                                              final Headers headers,
                                              final InputStream in,
                                              final int postLength)
focal_class.full_signature: private void handlePostMultipartRequest(final HttpServletRequestImpl.Builder builder,
                                              final Headers headers,
                                              final InputStream in,
                                              final int postLength)
focal_class.identifier: handlePostMultipartRequest
focal_class.modifiers: private
focal_class.parameters: (final HttpServletRequestImpl.Builder builder,
                                              final Headers headers,
                                              final InputStream in,
                                              final int postLength)
focal_class.return: void
focal_class.signature: void handlePostMultipartRequest(final HttpServletRequestImpl.Builder builder,
                                              final Headers headers,
                                              final InputStream in,
                                              final int postLength)
focal_method.body: public HttpServletRequestImpl createFromSocket(final Socket socket)
              throws IOException, ProtocolException {
  
          HttpServletRequestImpl.Builder builder = HttpServletRequestImpl.createNewBuilder();
  
          InputStream in = socket.getInputStream();
          // The order matters
  
          RequestStatus status;
          try {
              status = statusParser.parse(getStatusLine(in));
          } catch (MalformedInputException e) {
              throw new MalformedStatusLineException("Malformed status line " + e.getMessage());
          }
  
          int uriLengthExceededWith = status.getUri().length() - URI_MAX_LENGTH;
          if (uriLengthExceededWith > 0) {
              throw new UriTooLongProtocolException("Uri length exceeded max length with"
                      + uriLengthExceededWith + " characters");
          }
  
          if (!isValidProtocol(status.getProtocol())) {
              throw new UnsupportedProtocolException("Protocol " + status.getProtocol() + " is not supported");
          }
  
          assignSocketMetadata(socket, builder);
  
          try {
              builder.withGetParameters(queryStringParser.parse(status.getQueryString()));
          } catch (MalformedInputException e) {
              // This should never happen
          }
  
          Headers headers = computeHeaders(in);
  
          builder.withServletContext(getImplicitServletContext())
                  .withInputStream(in)
                  .withStatus(status)
                  .withPathTranslated(status.getUri()) // TODO There is no way to make it work under Android
                  .withPathInfo("")
                  .withRemoteUser(null)
                  .withPrincipal(null)
                  .withHeaders(headers)
                  .withCookies(getCookies(headers));
  
          if (status.getMethod().equalsIgnoreCase(HttpServletRequest.METHOD_POST)) {
              try {
                  handlePostRequest(builder, in, headers);
              } catch (MalformedInputException e) {
                  throw new ProtocolException("Malformed post input");
              }
          }
  
          return builder.build();
      }
focal_method.class_method_signature: HttpServletRequestImplFactory.createFromSocket(final Socket socket)
focal_method.full_signature: public HttpServletRequestImpl createFromSocket(final Socket socket)
focal_method.identifier: createFromSocket
focal_method.invocations: createNewBuilder getInputStream parse getStatusLine getMessage length getUri isValidProtocol getProtocol getProtocol assignSocketMetadata withGetParameters parse getQueryString computeHeaders withCookies withHeaders withPrincipal withRemoteUser withPathInfo withPathTranslated withStatus withInputStream withServletContext getImplicitServletContext getUri getCookies equalsIgnoreCase getMethod handlePostRequest build
focal_method.modifiers: public
focal_method.parameters: (final Socket socket)
focal_method.return: HttpServletRequestImpl
focal_method.signature: HttpServletRequestImpl createFromSocket(final Socket socket)