make it fit in allocated space

This commit is contained in:
philippe44
2023-03-27 17:09:27 -07:00
parent 7dfdd7b9e5
commit fc78b36c1f
24 changed files with 421 additions and 230 deletions

View File

@@ -15,7 +15,9 @@
#include "ByteStream.h"
#include "SocketStream.h"
#include "URLParser.h"
#ifndef BELL_DISABLE_FMT
#include "fmt/core.h"
#endif
#include "picohttpparser.h"
namespace bell {
@@ -29,11 +31,19 @@ class HTTPClient {
// Helper over ValueHeader, formatting a HTTP bytes range
struct RangeHeader {
static ValueHeader range(int32_t from, int32_t to) {
#ifndef BELL_DISABLE_FMT
return ValueHeader{"Range", fmt::format("bytes={}-{}", from, to)};
#else
return ValueHeader{"Range", "bytes=" + std::to_string(from) + "-" + std::to_string(to) };
#endif
}
static ValueHeader last(int32_t nbytes) {
#ifndef BELL_DISABLE_FMT
return ValueHeader{"Range", fmt::format("bytes=-{}", nbytes)};
#else
return ValueHeader{"Range", "bytes=-" + std::to_string(nbytes)};
#endif
}
};