@@ -31,22 +31,27 @@ HTTPServer::HTTPServer(std::vector<std::string> vhost_aliases, int port, std::st
3131 listenSocket = INVALID_SOCKET;
3232 listenPort = port;
3333
34- printf ( " Primary port: %i , disk path: %s \n " , port, diskpath.c_str ()) ;
34+ std::cout << " Primary port: " << port << " , disk path: " << diskpath.c_str () << std::endl ;
3535
3636 // Create a resource host serving the base path ./htdocs on disk
3737 ResourceHost* resHost = new ResourceHost (diskpath);
3838 hostList.push_back (resHost);
3939
4040 // Always serve up localhost/127.0.0.1 (which is why we only added one ResourceHost to hostList above)
41- char tmpstr[32 ];
41+ char tmpstr[128 ];
4242 sprintf (tmpstr, " localhost:%i" , listenPort);
4343 vhosts.insert (std::pair<std::string, ResourceHost*>(std::string (tmpstr).c_str (), resHost));
4444 sprintf (tmpstr, " 127.0.0.1:%i" , listenPort);
4545 vhosts.insert (std::pair<std::string, ResourceHost*>(std::string (tmpstr).c_str (), resHost));
4646
4747 // Setup the resource host serving htdocs to provide for the vhost aliases
4848 for (std::string vh : vhost_aliases) {
49- printf (" vhost: %s\n " , vh.c_str ());
49+ if ((vh.length () - 6 ) >= 128 ) {
50+ std::cout << " vhost " << vh << " too long, skipping!" << std::endl;
51+ continue ;
52+ }
53+
54+ std::cout << " vhost: " << vh << std::endl;
5055 sprintf (tmpstr, " %s:%i" , vh.c_str (), listenPort);
5156 vhosts.insert (std::pair<std::string, ResourceHost*>(std::string (tmpstr).c_str (), resHost));
5257 }
0 commit comments