Example #1
0
void Init_http11()
{

  VALUE mPuma = rb_define_module("Puma");

  DEF_GLOBAL(request_method, "REQUEST_METHOD");
  DEF_GLOBAL(request_uri, "REQUEST_URI");
  DEF_GLOBAL(fragment, "FRAGMENT");
  DEF_GLOBAL(query_string, "QUERY_STRING");
  DEF_GLOBAL(http_version, "HTTP_VERSION");
  DEF_GLOBAL(request_path, "REQUEST_PATH");

  eHttpParserError = rb_define_class_under(mPuma, "HttpParserError", rb_eIOError);
  rb_global_variable(&eHttpParserError);

  VALUE cHttpParser = rb_define_class_under(mPuma, "HttpParser", rb_cObject);
  rb_define_alloc_func(cHttpParser, HttpParser_alloc);
  rb_define_method(cHttpParser, "initialize", HttpParser_init, 0);
  rb_define_method(cHttpParser, "reset", HttpParser_reset, 0);
  rb_define_method(cHttpParser, "finish", HttpParser_finish, 0);
  rb_define_method(cHttpParser, "execute", HttpParser_execute, 3);
  rb_define_method(cHttpParser, "error?", HttpParser_has_error, 0);
  rb_define_method(cHttpParser, "finished?", HttpParser_is_finished, 0);
  rb_define_method(cHttpParser, "nread", HttpParser_nread, 0);
  rb_define_method(cHttpParser, "body", HttpParser_body, 0);
  init_common_fields();
}
Example #2
0
void Init_spyglass_parser()
{

    mSpyglass = rb_define_module("Spyglass");

    DEF_GLOBAL(empty, "");
    DEF_GLOBAL(http_prefix, "HTTP_");
    DEF_GLOBAL(request_method, "REQUEST_METHOD");
    DEF_GLOBAL(request_uri, "REQUEST_URI");
    DEF_GLOBAL(fragment, "FRAGMENT");
    DEF_GLOBAL(query_string, "QUERY_STRING");
    DEF_GLOBAL(http_version, "HTTP_VERSION");
    DEF_GLOBAL(request_path, "REQUEST_PATH");
    DEF_GLOBAL(content_length, "CONTENT_LENGTH");
    DEF_GLOBAL(http_content_length, "HTTP_CONTENT_LENGTH");
    DEF_GLOBAL(content_type, "CONTENT_TYPE");
    DEF_GLOBAL(http_content_type, "HTTP_CONTENT_TYPE");
    DEF_GLOBAL(gateway_interface, "GATEWAY_INTERFACE");
    DEF_GLOBAL(gateway_interface_value, "CGI/1.2");
    DEF_GLOBAL(server_name, "SERVER_NAME");
    DEF_GLOBAL(server_port, "SERVER_PORT");
    DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
    DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
    DEF_GLOBAL(http_host, "HTTP_HOST");
    DEF_GLOBAL(port_80, "80");
    DEF_GLOBAL(http_body, "rack.input");
    DEF_GLOBAL(url_scheme, "rack.url_scheme");
    DEF_GLOBAL(url_scheme_value, "http");
    DEF_GLOBAL(script_name, "SCRIPT_NAME");
    DEF_GLOBAL(path_info, "PATH_INFO");

    eHttpParserError = rb_define_class_under(mSpyglass, "InvalidRequest", rb_eIOError);

    cHttpParser = rb_define_class_under(mSpyglass, "HttpParser", rb_cObject);
    rb_define_alloc_func(cHttpParser, Spyglass_HttpParser_alloc);
    rb_define_method(cHttpParser, "initialize", Spyglass_HttpParser_init,0);
    rb_define_method(cHttpParser, "reset", Spyglass_HttpParser_reset,0);
    rb_define_method(cHttpParser, "finish", Spyglass_HttpParser_finish,0);
    rb_define_method(cHttpParser, "execute", Spyglass_HttpParser_execute,3);
    rb_define_method(cHttpParser, "error?", Spyglass_HttpParser_has_error,0);
    rb_define_method(cHttpParser, "finished?", Spyglass_HttpParser_is_finished,0);
    rb_define_method(cHttpParser, "nread", Spyglass_HttpParser_nread,0);
}
Example #3
0
void Init_http11()
{

  mMongrel = rb_define_module("Mongrel");

  DEF_GLOBAL(request_method, "REQUEST_METHOD");
  DEF_GLOBAL(request_uri, "REQUEST_URI");
  DEF_GLOBAL(fragment, "FRAGMENT");
  DEF_GLOBAL(query_string, "QUERY_STRING");
  DEF_GLOBAL(http_version, "HTTP_VERSION");
  DEF_GLOBAL(request_path, "REQUEST_PATH");
  DEF_GLOBAL(content_length, "CONTENT_LENGTH");
  DEF_GLOBAL(http_content_length, "HTTP_CONTENT_LENGTH");
  DEF_GLOBAL(content_type, "CONTENT_TYPE");
  DEF_GLOBAL(http_content_type, "HTTP_CONTENT_TYPE");
  DEF_GLOBAL(gateway_interface, "GATEWAY_INTERFACE");
  DEF_GLOBAL(gateway_interface_value, "CGI/1.2");
  DEF_GLOBAL(server_name, "SERVER_NAME");
  DEF_GLOBAL(server_port, "SERVER_PORT");
  DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
  DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
  DEF_GLOBAL(http_host, "HTTP_HOST");
  DEF_GLOBAL(mongrel_version, "Mongrel 1.2.0"); /* XXX Why is this defined here? */
  DEF_GLOBAL(server_software, "SERVER_SOFTWARE");
  DEF_GLOBAL(port_80, "80");

  eHttpParserError = rb_define_class_under(mMongrel, "HttpParserError", rb_eIOError);

  cHttpParser = rb_define_class_under(mMongrel, "HttpParser", rb_cObject);
  rb_define_alloc_func(cHttpParser, HttpParser_alloc);
  rb_define_method(cHttpParser, "initialize", HttpParser_init,0);
  rb_define_method(cHttpParser, "reset", HttpParser_reset,0);
  rb_define_method(cHttpParser, "finish", HttpParser_finish,0);
  rb_define_method(cHttpParser, "execute", HttpParser_execute,3);
  rb_define_method(cHttpParser, "error?", HttpParser_has_error,0);
  rb_define_method(cHttpParser, "finished?", HttpParser_is_finished,0);
  rb_define_method(cHttpParser, "nread", HttpParser_nread,0);
  init_common_fields();
}