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 "../db/jsobj.h"
00023
00024 namespace mongo {
00025
00026 class MiniWebServer : public Listener {
00027 public:
00028 MiniWebServer(const string &ip, int _port);
00029 virtual ~MiniWebServer() {}
00030
00031 virtual void doRequest(
00032 const char *rq,
00033 string url,
00034
00035 string& responseMsg,
00036 int& responseCode,
00037 vector<string>& headers,
00038 const SockAddr &from
00039 ) = 0;
00040
00041
00042
00043 static void parseParams( BSONObj & params , string query );
00044
00045 static string parseURL( const char * buf );
00046 static string parseMethod( const char * headers );
00047 static string getHeader( const char * headers , string name );
00048 static const char *body( const char *buf );
00049
00050 static string urlDecode(const char* s);
00051 static string urlDecode(string s) {return urlDecode(s.c_str());}
00052
00053 private:
00054 void accepted(int s, const SockAddr &from);
00055 static bool fullReceive( const char *buf );
00056 };
00057
00058 }