0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

tweaking webserver

This commit is contained in:
Dwight Merriman 2010-04-19 22:24:37 -04:00
parent ebbb932c3e
commit 5c6ab24ee2
2 changed files with 25 additions and 18 deletions

View File

@ -319,6 +319,29 @@ namespace mongo {
{ {
if ( url.size() > 1 ) { if ( url.size() > 1 ) {
if ( url.find( "/_status" ) == 0 ){
if ( ! allowed( rq , headers, from ) ){
responseCode = 401;
headers.push_back( "Content-Type: text/plain" );
responseMsg = "not allowed\n";
return;
}
headers.push_back( "Content-Type: application/json" );
generateServerStatus( url , responseMsg );
responseCode = 200;
return;
}
if ( ! cmdLine.rest ) {
responseCode = 403;
stringstream ss;
ss << "REST is not enabled. use --rest to turn on.\n";
ss << "check that port " << _port << " is secured for the network too.\n";
responseMsg = ss.str();
headers.push_back( "Content-Type: text/plain" );
return;
}
/* run a command from the web ui */ /* run a command from the web ui */
const char *p = url.c_str(); const char *p = url.c_str();
if( *p == '/' ) { if( *p == '/' ) {
@ -350,23 +373,6 @@ namespace mongo {
} }
} }
if ( url.find( "/_status" ) == 0 ){
if ( ! allowed( rq , headers, from ) ){
responseCode = 401;
responseMsg = "not allowed\n";
return;
}
headers.push_back( "Content-Type: application/json" );
generateServerStatus( url , responseMsg );
responseCode = 200;
return;
}
if ( ! cmdLine.rest ){
responseCode = 403;
responseMsg = "rest is not enabled. use --rest to turn on";
return;
}
if ( ! allowed( rq , headers, from ) ){ if ( ! allowed( rq , headers, from ) ){
responseCode = 401; responseCode = 401;
responseMsg = "not allowed\n"; responseMsg = "not allowed\n";

View File

@ -41,9 +41,10 @@ namespace mongo {
assert(!"You must overwrite one of the accepted methods"); assert(!"You must overwrite one of the accepted methods");
} }
const int _port;
private: private:
string _ip; string _ip;
int _port;
bool _logConnect; bool _logConnect;
}; };