#ifndef node_http_h #define node_http_h #include #include "net.h" #include namespace node { class HTTPConnection : public Connection { public: static void Initialize (v8::Handle target); static v8::Persistent client_constructor_template; static v8::Persistent server_constructor_template; protected: static v8::Handle NewClient (const v8::Arguments& args); static v8::Handle NewServer (const v8::Arguments& args); HTTPConnection (enum http_parser_type type) : Connection() { http_parser_init (&parser_, type); parser_.on_message_begin = on_message_begin; parser_.on_uri = on_uri; parser_.on_header_field = on_header_field; parser_.on_header_value = on_header_value; parser_.on_headers_complete = on_headers_complete; parser_.on_body = on_body; parser_.on_message_complete = on_message_complete; parser_.data = this; } void OnReceive (const void *buf, size_t len); static int on_message_begin (http_parser *parser); static int on_uri (http_parser *parser, const char *at, size_t length); static int on_header_field (http_parser *parser, const char *buf, size_t len); static int on_header_value (http_parser *parser, const char *buf, size_t len); static int on_headers_complete (http_parser *parser); static int on_body (http_parser *parser, const char *buf, size_t len); static int on_message_complete (http_parser *parser); http_parser parser_; friend class HTTPServer; }; class HTTPServer : public Server { public: static void Initialize (v8::Handle target); static v8::Persistent constructor_template; protected: static v8::Handle New (const v8::Arguments& args); HTTPServer (void) : Server() {} v8::Handle GetConnectionTemplate (void); Connection* UnwrapConnection (v8::Local connection); }; } // namespace node #endif