+ Stream *stream = client->stream;
+ if (stream->encoding == Stream::STREAM_ENCODING_RAW) {
+ client->header_or_error = stream->http_header +
+ "\r\n" +
+ stream->stream_header;
+ } else if (stream->encoding == Stream::STREAM_ENCODING_METACUBE) {
+ client->header_or_error = stream->http_header +
+ "Content-encoding: metacube\r\n" +
+ "\r\n";
+ if (!stream->stream_header.empty()) {
+ metacube2_block_header hdr;
+ memcpy(hdr.sync, METACUBE2_SYNC, sizeof(hdr.sync));
+ hdr.size = htonl(stream->stream_header.size());
+ hdr.flags = htons(METACUBE_FLAGS_HEADER);
+ hdr.csum = htons(metacube2_compute_crc(&hdr));
+ client->header_or_error.append(
+ string(reinterpret_cast<char *>(&hdr), sizeof(hdr)));
+ }
+ client->header_or_error.append(stream->stream_header);
+ } else {
+ assert(false);
+ }