Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Print user agent into log

  • Loading branch information...
commit b7bcc401e70c7992beee1f5835f1b8eb583f1270 1 parent 82ead0a
DennisOSRM authored
View
1  Server/BasicDatastructures.h
@@ -53,6 +53,7 @@ enum CompressionType {
struct Request {
std::string uri;
std::string referrer;
+ std::string agent;
boost::asio::ip::address endpoint;
};
View
2  Server/RequestHandler.h
@@ -58,7 +58,7 @@ class RequestHandler : private boost::noncopyable {
Tm=localtime(&ltime);
INFO((Tm->tm_mday < 10 ? "0" : "" ) << Tm->tm_mday << "-" << (Tm->tm_mon < 10 ? "0" : "" ) << Tm->tm_mon << "-" << 1900+Tm->tm_year << " " << (Tm->tm_hour < 10 ? "0" : "" ) << Tm->tm_hour << ":" << (Tm->tm_min < 10 ? "0" : "" ) << Tm->tm_min << ":" << (Tm->tm_sec < 10 ? "0" : "" ) << Tm->tm_sec << " " <<
- req.endpoint.to_string() << " " << req.referrer << " " << request );
+ req.endpoint.to_string() << " " << req.referrer << ( 0 == req.referrer.length() ? "- " :" ") << req.agent << ( 0 == req.agent.length() ? "- " :" ") << request );
std::string command;
std::size_t firstAmpPosition = request.find_first_of("?");
command = request.substr(1,firstAmpPosition-1);
View
5 Server/RequestParser.h
@@ -164,9 +164,12 @@ class RequestParser {
*compressionType = gzipRFC1952;
}
- if(header.name == "Referer")
+ if("Referer" == header.name)
req.referrer = header.value;
+ if("User-Agent" == header.name)
+ req.agent = header.value;
+
if (input == '\r') {
state_ = expecting_newline_3;
return boost::indeterminate;
Please sign in to comment.
Something went wrong with that request. Please try again.