0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00
mongodb/util/miniwebserver.h
Eliot Horowitz c3d792be34 getHeader
2009-01-30 15:05:28 -05:00

57 lines
1.6 KiB
C++

// miniwebserver.h
/**
* Copyright (C) 2008 10gen Inc.
*
* 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.
*
* 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.
*
* 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"
namespace mongo {
class MiniWebServer {
public:
MiniWebServer();
bool init(int port);
void run();
virtual void doRequest(
const char *rq, // the full request
string url,
// set these and return them:
string& responseMsg,
int& responseCode,
vector<string>& headers // if completely empty, content-type: text/html will be added
) = 0;
protected:
string parseURL( const char * buf );
string parseMethod( const char * headers );
string getHeader( const char * headers , string name );
void parseParams( map<string,string> & params , string query );
static const char *body( const char *buf );
private:
void accepted(int s);
static bool fullReceive( const char *buf );
int sock;
};
} // namespace mongo