1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix #277, refine http server refer to go http-framework. 2.0.98

This commit is contained in:
winlin 2015-01-17 23:00:40 +08:00
parent 9bbbaad288
commit cbed2bbca4
9 changed files with 148 additions and 1116 deletions

View file

@ -41,54 +41,25 @@ class SrsHttpParser;
class SrsHttpMessage;
class SrsHttpHandler;
// for http root.
class SrsHttpRoot : public SrsHttpHandler
// for http server.
class SrsHttpServer
{
public:
SrsHttpRoot();
virtual ~SrsHttpRoot();
SrsGoHttpServeMux mux;
public:
SrsHttpServer();
virtual ~SrsHttpServer();
public:
virtual int initialize();
virtual int best_match(const char* path, int length, SrsHttpHandlerMatch** ppmatch);
protected:
virtual bool is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase);
virtual int do_process_request(SrsStSocket* skt, SrsHttpMessage* req);
};
class SrsHttpVhost : public SrsHttpHandler
{
private:
std::string _vhost;
std::string _mount;
std::string _dir;
public:
SrsHttpVhost(std::string vhost, std::string mount, std::string dir);
virtual ~SrsHttpVhost();
public:
virtual bool can_handle(const char* path, int length, const char** pchild);
protected:
virtual bool is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase);
virtual int do_process_request(SrsStSocket* skt, SrsHttpMessage* req);
private:
virtual int response_regular_file(SrsStSocket* skt, SrsHttpMessage* req, std::string fullpath);
virtual int response_flv_file(SrsStSocket* skt, SrsHttpMessage* req, std::string fullpath);
virtual int response_flv_file2(SrsStSocket* skt, SrsHttpMessage* req, std::string fullpath, int offset);
virtual int response_ts_file(SrsStSocket* skt, SrsHttpMessage* req, std::string fullpath);
virtual std::string get_request_file(SrsHttpMessage* req);
public:
virtual std::string vhost();
virtual std::string mount();
virtual std::string dir();
};
class SrsHttpConn : public SrsConnection
{
private:
SrsHttpParser* parser;
SrsHttpHandler* handler;
bool requires_crossdomain;
SrsHttpServer* mux;
public:
SrsHttpConn(SrsServer* srs_server, st_netfd_t client_stfd, SrsHttpHandler* _handler);
SrsHttpConn(SrsServer* svr, st_netfd_t fd, SrsHttpServer* m);
virtual ~SrsHttpConn();
public:
virtual void kbps_resample();
@ -99,7 +70,7 @@ public:
protected:
virtual int do_cycle();
private:
virtual int process_request(SrsStSocket* skt, SrsHttpMessage* req);
virtual int process_request(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r);
};
#endif