ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Smersh/Daemon.cpp
(Generate patch)

Comparing Smersh/Daemon.cpp (file contents):
Revision 177 by Douglas Thrift, 2004-06-26T01:26:41-07:00 vs.
Revision 178 by Douglas Thrift, 2004-06-29T13:15:51-07:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include <arpa/inet.h>
8 + #include <sys/utsname.h>
9  
10   #include "Daemon.hpp"
11  
# Line 82 | Line 83 | Daemon::Status Daemon::request(istream&
83   void Daemon::response(ostream& sout, Status status)
84   {
85          sout << "HTTP/1.1 " << status << ' ' << reason(status) << crlf << "Date: "
86 <                << date() << crlf << "Server: Smersh/0.9" << crlf
86 >                << date() << crlf << "Server: " << server() << crlf
87                  << "Connection: close" << crlf;
88   }
89  
90 + string Daemon::server()
91 + {
92 +        utsname system;
93 +
94 +        uname(&system);
95 +
96 +        return string("Smersh/0.9 (") + system.sysname + ')';
97 + }
98 +
99   streamsize Daemon::error(ostream& sout, Status status)
100   {
101          string reason(this->reason(status));
# Line 93 | Line 103 | streamsize Daemon::error(ostream& sout,
103  
104          error << "<html><head><title>" << status << ' ' << reason << "</title></hea"
105                  << "d><body><h1>" << reason << "</h1><p>Mistakes were made, deal with t"
106 <                << "hem.</p><hr /><address>Smersh/0.9</address></body></html>\n";
106 >                << "hem.</p><hr /><address>" << server() + "</address></body></html>\n";
107          sout << "Content-Length: " << error.str().length() << crlf
108                  << "Content-Type: text/html; charset=UTF-8\r\n\r\n" << error.str();
109  
# Line 159 | Line 169 | int Daemon::handle(api::TcpSocket* clien
169          ofstream fout(this->log.c_str(), ios_base::app);
170  
171          fout << ip(*client) << " - - " << date(true) << ' ' << log.str() << '\n';
172 +        sio << flush;
173 +
174 +        client->ShutdownWrite();
175  
176          delete client;
177   }
# Line 176 | Line 189 | void Daemon::headers(istream& sin, Envir
189                  istringstream input(line);
190                  string name, value;
191  
192 <                ::getline(input, name, ':');
192 >                std::getline(input, name, ':');
193                  getline(input, value);
194  
195                  for (char next(sin.peek()); next == ' ' || next == '\t'; next =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines