00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #pragma once
00019
00020 #include "../../pch.h"
00021 #include "message.h"
00022 #include "message_port.h"
00023 #include "listen.h"
00024 #include "../../db/jsobj.h"
00025
00026 namespace mongo {
00027
00028 class MiniWebServer : public Listener {
00029 public:
00030 MiniWebServer(const string &ip, int _port);
00031 virtual ~MiniWebServer() {}
00032
00033 virtual void doRequest(
00034 const char *rq,
00035 string url,
00036
00037 string& responseMsg,
00038 int& responseCode,
00039 vector<string>& headers,
00040 const SockAddr &from
00041 ) = 0;
00042
00043
00044
00045 static void parseParams( BSONObj & params , string query );
00046
00047 static string parseURL( const char * buf );
00048 static string parseMethod( const char * headers );
00049 static string getHeader( const char * headers , string name );
00050 static const char *body( const char *buf );
00051
00052 static string urlDecode(const char* s);
00053 static string urlDecode(string s) {return urlDecode(s.c_str());}
00054
00055 private:
00056 void accepted(int s, const SockAddr &from);
00057 static bool fullReceive( const char *buf );
00058 };
00059
00060 }