X-Git-Url: https://git.sesse.net/?p=cubemap;a=blobdiff_plain;f=httpinput.cpp;h=354e4b9885aa0d9be0622c4f85d1ec23e67be5d4;hp=1db4f91f16e0221f6afcf886111142d7a36a097e;hb=ca9624c43b968a0f29ea44e47851ff686bb64bb6;hpb=239a9eab1a2468b401183745a24b2fbd590a6998 diff --git a/httpinput.cpp b/httpinput.cpp index 1db4f91..354e4b9 100644 --- a/httpinput.cpp +++ b/httpinput.cpp @@ -23,6 +23,7 @@ #include "server.h" #include "serverpool.h" #include "parse.h" +#include "version.h" #include "state.pb.h" using namespace std; @@ -56,6 +57,18 @@ HTTPInput::HTTPInput(const InputProto &serialized) parse_url(url, &protocol, &host, &port, &path); // Don't care if it fails. } +void HTTPInput::close_socket() +{ + int ret; + do { + ret = close(sock); + } while (ret == -1 && errno == EINTR); + + if (ret == -1) { + perror("close()"); + } +} + InputProto HTTPInput::serialize() const { InputProto serialized; @@ -163,7 +176,7 @@ bool HTTPInput::parse_response(const std::string &request) // TODO: Make case-insensitive. // XXX: Use a Via: instead? if (parameters.count("Server") == 0) { - parameters.insert(make_pair("Server", "metacube/0.1")); + parameters.insert(make_pair("Server", SERVER_IDENTIFICATION)); } else { for (multimap::iterator it = parameters.begin(); it != parameters.end(); @@ -171,7 +184,7 @@ bool HTTPInput::parse_response(const std::string &request) if (it->first != "Server") { continue; } - it->second = "metacube/0.1 (reflecting: " + it->second + ")"; + it->second = SERVER_IDENTIFICATION " (reflecting: " + it->second + ")"; } } @@ -214,6 +227,7 @@ void HTTPInput::do_work() request.clear(); request_bytes_sent = 0; response.clear(); + pending_data.clear(); { string protocol; // Thrown away.