Switch to clang
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,8 +1,8 @@
|
|||||||
example_simple: example_simple.o fastcgi.o fastcgi_conn.o fastcgi_request.o buffer.o
|
example_simple: example_simple.o fastcgi.o fastcgi_conn.o fastcgi_request.o buffer.o
|
||||||
g++ -std=gnu++2a -o example_simple example_simple.o fastcgi.o fastcgi_conn.o fastcgi_request.o buffer.o -lgflags -lglog -lpthread
|
clang++ -std=gnu++2a -o example_simple example_simple.o fastcgi.o fastcgi_conn.o fastcgi_request.o buffer.o -lgflags -lglog -lpthread
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm --force exmaple_simple *.o
|
rm --force exmaple_simple *.o
|
||||||
|
|
||||||
.cpp.o:
|
.cpp.o:
|
||||||
g++ -std=gnu++2a -o $@ -c $<
|
clang++ -std=gnu++2a -Wall -Werror -o $@ -c $<
|
||||||
|
|||||||
BIN
example_simple
BIN
example_simple
Binary file not shown.
@@ -100,10 +100,10 @@ void FastCGIConn::WriteBlock(uint8_t type, uint16_t request_id, const std::vecto
|
|||||||
content_length += vec.iov_len;
|
content_length += vec.iov_len;
|
||||||
}
|
}
|
||||||
header.SetContentLength(content_length);
|
header.SetContentLength(content_length);
|
||||||
out_vecs.push_back(std::move(iovec{
|
out_vecs.push_back(iovec{
|
||||||
.iov_base = &header,
|
.iov_base = &header,
|
||||||
.iov_len = sizeof(header),
|
.iov_len = sizeof(header),
|
||||||
}));
|
});
|
||||||
|
|
||||||
for (auto& vec : vecs) {
|
for (auto& vec : vecs) {
|
||||||
out_vecs.push_back(vec);
|
out_vecs.push_back(vec);
|
||||||
@@ -121,10 +121,10 @@ void FastCGIConn::WriteEnd(uint16_t request_id, uint8_t status) {
|
|||||||
end.SetAppStatus(status);
|
end.SetAppStatus(status);
|
||||||
|
|
||||||
std::vector<iovec> vecs;
|
std::vector<iovec> vecs;
|
||||||
vecs.push_back(std::move(iovec{
|
vecs.push_back(iovec{
|
||||||
.iov_base = &end,
|
.iov_base = &end,
|
||||||
.iov_len = sizeof(end),
|
.iov_len = sizeof(end),
|
||||||
}));
|
});
|
||||||
WriteBlock(3, request_id, vecs);
|
WriteBlock(3, request_id, vecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ FastCGIRequest::FastCGIRequest(uint16_t request_id, FastCGIConn* conn)
|
|||||||
conn_(conn) {}
|
conn_(conn) {}
|
||||||
|
|
||||||
void FastCGIRequest::AddParam(const std::string_view& key, const std::string_view& value) {
|
void FastCGIRequest::AddParam(const std::string_view& key, const std::string_view& value) {
|
||||||
params_.try_emplace(std::move(std::string(key)), std::move(std::string(value)));
|
params_.try_emplace(std::string(key), std::string(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FastCGIRequest::AddIn(const std::string_view& in) {
|
void FastCGIRequest::AddIn(const std::string_view& in) {
|
||||||
@@ -27,37 +27,37 @@ void FastCGIRequest::Write(const std::vector<std::pair<std::string_view, std::st
|
|||||||
CHECK(headers.empty() || !body_sent_);
|
CHECK(headers.empty() || !body_sent_);
|
||||||
|
|
||||||
for (const auto& header : headers) {
|
for (const auto& header : headers) {
|
||||||
vecs.push_back(std::move(iovec{
|
vecs.push_back(iovec{
|
||||||
.iov_base = const_cast<char*>(header.first.data()),
|
.iov_base = const_cast<char*>(header.first.data()),
|
||||||
.iov_len = header.first.size(),
|
.iov_len = header.first.size(),
|
||||||
}));
|
});
|
||||||
vecs.push_back(std::move(iovec{
|
vecs.push_back(iovec{
|
||||||
.iov_base = const_cast<char*>(": "),
|
.iov_base = const_cast<char*>(": "),
|
||||||
.iov_len = 2,
|
.iov_len = 2,
|
||||||
}));
|
});
|
||||||
vecs.push_back(std::move(iovec{
|
vecs.push_back(iovec{
|
||||||
.iov_base = const_cast<char*>(header.second.data()),
|
.iov_base = const_cast<char*>(header.second.data()),
|
||||||
.iov_len = header.second.size(),
|
.iov_len = header.second.size(),
|
||||||
}));
|
});
|
||||||
vecs.push_back(std::move(iovec{
|
vecs.push_back(iovec{
|
||||||
.iov_base = const_cast<char*>("\n"),
|
.iov_base = const_cast<char*>("\n"),
|
||||||
.iov_len = 1,
|
.iov_len = 1,
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!body.empty() && !body_sent_) {
|
if (!body.empty() && !body_sent_) {
|
||||||
body_sent_ = true;
|
body_sent_ = true;
|
||||||
vecs.push_back(std::move(iovec{
|
vecs.push_back(iovec{
|
||||||
.iov_base = const_cast<char*>("\n"),
|
.iov_base = const_cast<char*>("\n"),
|
||||||
.iov_len = 1,
|
.iov_len = 1,
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& chunk : body) {
|
for (const auto& chunk : body) {
|
||||||
vecs.push_back(std::move(iovec{
|
vecs.push_back(iovec{
|
||||||
.iov_base = const_cast<char*>(chunk.data()),
|
.iov_base = const_cast<char*>(chunk.data()),
|
||||||
.iov_len = chunk.size(),
|
.iov_len = chunk.size(),
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_->WriteOutput(request_id_, vecs);
|
conn_->WriteOutput(request_id_, vecs);
|
||||||
|
|||||||
Reference in New Issue
Block a user