#include "tile/net/http/http_request.h"

namespace tile {
void
HttpRequest::clear() noexcept
{
    HttpMessage::clear();
}

std::string
HttpRequest::ToString() const
{
    std::string result;
    result += Format("{} {} {}\r\n", ToSlice(method_), uri_, ToSlice(version()));
    for (auto header : *headers()) {
        auto &&key   = header.first;
        auto &&value = header.second;
        result += Format("{}: {}\r\n", key, value);
    }

    result += "\r\n";
    if (auto ptr = noncontiguous_body()) {
        result += FlattenSlow(*ptr);
    } else {
        result += *body();
    }
    return result;
}
}// namespace tile
