mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::http: Remove the no-longer used content related.
This commit is contained in:
parent
143c867ad8
commit
daa1d6481c
2 changed files with 0 additions and 162 deletions
|
@ -217,34 +217,11 @@ struct ircd::http::headers
|
|||
headers(parse::capstan &, const closure & = {});
|
||||
};
|
||||
|
||||
/// Represents the content of an HTTP request after the head.
|
||||
///
|
||||
/// Use the request::content / response::content wrappers. They ensure the
|
||||
/// proper amount of content is read and the tape is in the right position
|
||||
/// for the next request with exception safety. In other words, this object
|
||||
/// ensures the capstan is in the proper place for the next request no matter
|
||||
/// what happens; whether an exception happened, or whether the user simply
|
||||
/// didn't care to read the content. The capstan MUST advance Content-Length
|
||||
/// bytes in any case.
|
||||
///
|
||||
struct ircd::http::content
|
||||
:string_view
|
||||
{
|
||||
IRCD_OVERLOAD(discard)
|
||||
IRCD_OVERLOAD(chunked)
|
||||
|
||||
content(parse::capstan &, const size_t &length, discard_t);
|
||||
content(parse::capstan &, const size_t &length);
|
||||
content(parse::capstan &, chunked_t);
|
||||
content() = default;
|
||||
};
|
||||
|
||||
/// HTTP request suite. Functionality to send and receive requests.
|
||||
///
|
||||
struct ircd::http::request
|
||||
{
|
||||
struct head;
|
||||
struct content;
|
||||
|
||||
using proffer = std::function<void (const head &)>;
|
||||
|
||||
|
@ -280,26 +257,11 @@ struct ircd::http::request::head
|
|||
head() = default;
|
||||
};
|
||||
|
||||
/// Represents an HTTP request content. This is only for receiving content.
|
||||
///
|
||||
struct ircd::http::request::content
|
||||
:http::content
|
||||
{
|
||||
content(parse::capstan &pc, const head &h, discard_t)
|
||||
:http::content{pc, h.content_length, discard}
|
||||
{}
|
||||
|
||||
content(parse::capstan &pc, const head &h)
|
||||
:http::content{pc, h.content_length}
|
||||
{}
|
||||
};
|
||||
|
||||
/// HTTP response suite. Functionality to send and receive responses.
|
||||
///
|
||||
struct ircd::http::response
|
||||
{
|
||||
struct head;
|
||||
struct content;
|
||||
struct chunked;
|
||||
|
||||
using write_closure = std::function<void (const ilist<const const_buffer> &)>;
|
||||
|
@ -352,23 +314,3 @@ struct ircd::http::response::head
|
|||
head(parse::capstan &pc, const headers::closure &c = {});
|
||||
head() = default;
|
||||
};
|
||||
|
||||
/// Represents an HTTP response content. This is for receiving only.
|
||||
///
|
||||
struct ircd::http::response::content
|
||||
:http::content
|
||||
{
|
||||
content(parse::capstan &pc, const head &h, discard_t)
|
||||
:http::content{pc, h.content_length, discard}
|
||||
{}
|
||||
|
||||
content(parse::capstan &pc, const head &h, chunked_t)
|
||||
:http::content{pc, chunked}
|
||||
{}
|
||||
|
||||
content(parse::capstan &pc, const head &h)
|
||||
:http::content{pc, h.content_length}
|
||||
{}
|
||||
|
||||
content() = default;
|
||||
};
|
||||
|
|
104
ircd/http.cc
104
ircd/http.cc
|
@ -466,110 +466,6 @@ ircd::http::response::head::head(parse::capstan &pc,
|
|||
{
|
||||
}
|
||||
|
||||
ircd::http::content::content(parse::capstan &pc,
|
||||
chunked_t)
|
||||
:string_view{[&pc]
|
||||
{
|
||||
size_t size;
|
||||
pc([&size](const char *&start, const char *const &stop)
|
||||
{
|
||||
static const auto &grammar
|
||||
{
|
||||
parser.chunk_size
|
||||
};
|
||||
|
||||
if(!qi::parse(start, stop, grammar, size))
|
||||
{
|
||||
size = 0;
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
});
|
||||
|
||||
if(size >= pc.remaining() - 2)
|
||||
throw parse::buffer_error("parse buffer must be for %zu bytes of chunk content + crlf",
|
||||
size + 2);
|
||||
|
||||
const string_view ret
|
||||
{
|
||||
pc.read, pc.read + size
|
||||
};
|
||||
|
||||
if(size)
|
||||
{
|
||||
pc.reader(pc.read, pc.read + size);
|
||||
pc.parsed = pc.read;
|
||||
}
|
||||
|
||||
pc([](const char *&start, const char *const &stop)
|
||||
{
|
||||
static const auto &grammar
|
||||
{
|
||||
parser.CRLF
|
||||
};
|
||||
|
||||
return qi::parse(start, stop, grammar);
|
||||
});
|
||||
|
||||
return ret;
|
||||
}()}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::http::content::content(parse::capstan &pc,
|
||||
const size_t &length)
|
||||
:string_view{[&pc, &length]
|
||||
{
|
||||
const char *const base(pc.parsed);
|
||||
const size_t have(std::min(pc.unparsed(), length));
|
||||
size_t remain(length - have);
|
||||
pc.parsed += have;
|
||||
|
||||
while(remain && pc.remaining())
|
||||
{
|
||||
const auto read_max(std::min(remain, pc.remaining()));
|
||||
pc.reader(pc.read, pc.read + read_max);
|
||||
remain -= pc.unparsed();
|
||||
pc.parsed = pc.read;
|
||||
}
|
||||
|
||||
//assert(pc.parsed == base + length);
|
||||
if(unlikely(pc.parsed < base + length))
|
||||
throw parse::buffer_error
|
||||
{
|
||||
"parse buffer short by %zu to hold %zu total bytes of content",
|
||||
remain,
|
||||
length
|
||||
};
|
||||
|
||||
if(pc.remaining())
|
||||
*pc.read = '\0';
|
||||
|
||||
assert(pc.parsed == pc.read);
|
||||
return string_view { base, pc.parsed };
|
||||
}()}
|
||||
{
|
||||
}
|
||||
|
||||
ircd::http::content::content(parse::capstan &pc,
|
||||
const size_t &length,
|
||||
discard_t)
|
||||
:string_view{}
|
||||
{
|
||||
static char buf[512] alignas(16);
|
||||
|
||||
const size_t have(std::min(pc.unparsed(), length));
|
||||
size_t remain(length - have);
|
||||
pc.read -= have;
|
||||
while(remain)
|
||||
{
|
||||
char *start(buf);
|
||||
__builtin_prefetch(start, 1, 0); // 1 = write, 0 = no cache
|
||||
pc.reader(start, start + std::min(remain, sizeof(buf)));
|
||||
remain -= std::distance(buf, start);
|
||||
}
|
||||
}
|
||||
|
||||
ircd::http::headers::headers(parse::capstan &pc,
|
||||
const closure &c)
|
||||
:string_view{[&pc, &c]
|
||||
|
|
Loading…
Reference in a new issue