]> git.sesse.net Git - cubemap/blobdiff - httpinput.cpp
Fix an issue where access.log would have the wrong timestamp.
[cubemap] / httpinput.cpp
index 7853388624ef7e9de926e883a6bd1e83ad4c6560..50a975cfece1fa70f9535b553fc6c7f322571579 100644 (file)
@@ -24,6 +24,7 @@
 #include "serverpool.h"
 #include "state.pb.h"
 #include "stream.h"
+#include "timespec.h"
 #include "util.h"
 #include "version.h"
 
@@ -31,24 +32,6 @@ using namespace std;
 
 extern ServerPool *servers;
 
-namespace {
-
-// Compute b-a.
-timespec clock_diff(const timespec &a, const timespec &b)
-{
-       timespec ret;
-       ret.tv_sec = b.tv_sec - a.tv_sec;
-       ret.tv_nsec = b.tv_nsec - a.tv_nsec;
-       if (ret.tv_nsec < 0) {
-               ret.tv_sec--;
-               ret.tv_nsec += 1000000000;
-       }
-       assert(ret.tv_nsec >= 0);
-       return ret;
-}
-
-}  // namespace
-
 HTTPInput::HTTPInput(const string &url)
        : state(NOT_CONNECTED),
          url(url),
@@ -200,7 +183,7 @@ int HTTPInput::lookup_and_connect(const string &host, const string &port)
        return -1;
 }
        
-bool HTTPInput::parse_response(const std::string &request)
+bool HTTPInput::parse_response(const string &request)
 {
        vector<string> lines = split_lines(response);
        if (lines.empty()) {
@@ -328,6 +311,13 @@ void HTTPInput::do_work()
                                        log(WARNING, "[%s] Failed to parse URL '%s'", url.c_str(), url.c_str());
                                        break;
                                }
+
+                               // Remove the brackets around IPv6 address literals.
+                               // TODO: See if we can join this with the code in parse_ip_address(),
+                               // or maybe even more it into parse_url().
+                               if (!host.empty() && host[0] == '[' && host[host.size() - 1] == ']') {
+                                       host = host.substr(1, host.size() - 2);
+                               }
                        }
 
                        sock = lookup_and_connect(host, port);
@@ -532,8 +522,8 @@ void HTTPInput::process_data(char *ptr, size_t bytes)
                        has_metacube_header = false;
                        continue;
                }
-               if (size > 1048576) {
-                       log(WARNING, "[%s] Metacube block of %d bytes (flags=%x); corrupted header?",
+               if (size > 10485760) {
+                       log(WARNING, "[%s] Metacube block of %d bytes (flags=%x); corrupted header??",
                                url.c_str(), size, flags);
                }