Convenience constructor for FastCGIHeader
This commit is contained in:
@@ -3,7 +3,13 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
struct FastCGIHeader {
|
struct FastCGIHeader {
|
||||||
uint8_t version;
|
FastCGIHeader(uint8_t type_in, uint16_t request_id, uint16_t content_length)
|
||||||
|
: type(type_in) {
|
||||||
|
SetRequestId(request_id);
|
||||||
|
SetContentLength(content_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t version = 1;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
private:
|
private:
|
||||||
uint16_t request_id_; // network byte order
|
uint16_t request_id_; // network byte order
|
||||||
|
|||||||
@@ -40,21 +40,11 @@ void FastCGIRequest::WriteBody(const std::string_view& body) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FastCGIRequest::End() {
|
void FastCGIRequest::End() {
|
||||||
FastCGIHeader output_header;
|
|
||||||
FastCGIHeader end_header;
|
|
||||||
FastCGIEndRequest end;
|
|
||||||
|
|
||||||
const auto output_len = out_buf_.ReadMaxLen();
|
const auto output_len = out_buf_.ReadMaxLen();
|
||||||
|
|
||||||
output_header.version = 1;
|
FastCGIHeader output_header(6, request_id_, output_len);
|
||||||
output_header.type = 6;
|
FastCGIEndRequest end;
|
||||||
output_header.SetRequestId(request_id_);
|
FastCGIHeader end_header(3, request_id_, sizeof(end));
|
||||||
output_header.SetContentLength(output_len);
|
|
||||||
|
|
||||||
end_header.version = 1;
|
|
||||||
end_header.type = 3;
|
|
||||||
end_header.SetRequestId(request_id_);
|
|
||||||
end_header.SetContentLength(sizeof(end));
|
|
||||||
|
|
||||||
std::vector<iovec> vecs{
|
std::vector<iovec> vecs{
|
||||||
iovec{
|
iovec{
|
||||||
|
|||||||
Reference in New Issue
Block a user