0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 17:10:48 +01:00
mongodb/util/miniwebserver.h

50 lines
1.3 KiB
C
Raw Normal View History

2008-11-30 02:01:58 +01:00
// miniwebserver.h
/**
* Copyright (C) 2008 10gen Inc.
2008-12-29 02:28:49 +01:00
*
2008-11-30 02:01:58 +01:00
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
2008-12-29 02:28:49 +01:00
*
2008-11-30 02:01:58 +01:00
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2008-12-29 02:28:49 +01:00
*
2008-11-30 02:01:58 +01:00
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "../grid/message.h"
2008-12-29 02:28:49 +01:00
class MiniWebServer {
2008-11-30 02:01:58 +01:00
public:
MiniWebServer();
bool init(int port);
void run();
virtual void doRequest(
const char *rq, // the full request
string url,
// set these and return them:
2008-12-29 02:28:49 +01:00
string& responseMsg,
2008-11-30 02:01:58 +01:00
int& responseCode,
vector<string>& headers // if completely empty, content-type: text/html will be added
2008-12-29 02:28:49 +01:00
) = 0;
2008-11-30 02:01:58 +01:00
2008-12-31 20:58:42 +01:00
protected:
string parseURL( const char * buf );
string parseMethod( const char * headers );
void parseParams( map<string,string> & params , string query );
2008-11-30 02:01:58 +01:00
private:
void accepted(int s);
int sock;
};