]> git.sesse.net Git - cubemap/commitdiff
Do not bother making a METACUBE_FLAGS_HEADER block if it is empty.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 17 Apr 2013 23:10:14 +0000 (01:10 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 17 Apr 2013 23:10:14 +0000 (01:10 +0200)
server.cpp

index e4ea647c64d05555505f3f18358f4e9b642d5370..8282a562863deea72c1294cb55f8e0a0100f6a8d 100644 (file)
@@ -470,16 +470,18 @@ void Server::construct_header(Client *client)
                        "\r\n" +
                        stream->stream_header;
        } else if (stream->encoding == Stream::STREAM_ENCODING_METACUBE) {
                        "\r\n" +
                        stream->stream_header;
        } else if (stream->encoding == Stream::STREAM_ENCODING_METACUBE) {
-               metacube_block_header hdr;
-               memcpy(hdr.sync, METACUBE_SYNC, sizeof(hdr.sync));
-               hdr.size = htonl(stream->stream_header.size());
-               hdr.flags = htonl(METACUBE_FLAGS_HEADER);
-
                client->header_or_error = stream->http_header +
                        "Content-encoding: metacube\r\n" +
                client->header_or_error = stream->http_header +
                        "Content-encoding: metacube\r\n" +
-                       "\r\n" +
-                       string(reinterpret_cast<char *>(&hdr), sizeof(hdr)) +
-                       stream->stream_header;
+                       "\r\n";
+               if (!stream->stream_header.empty()) {
+                       metacube_block_header hdr;
+                       memcpy(hdr.sync, METACUBE_SYNC, sizeof(hdr.sync));
+                       hdr.size = htonl(stream->stream_header.size());
+                       hdr.flags = htonl(METACUBE_FLAGS_HEADER);
+                       client->header_or_error.append(
+                               string(reinterpret_cast<char *>(&hdr), sizeof(hdr)));
+               }
+               client->header_or_error.append(stream->stream_header);
        } else {
                assert(false);
        }
        } else {
                assert(false);
        }