mirror of
https://github.com/drogonframework/drogon.git
synced 2025-07-26 00:00:47 -04:00
Compare commits
5 Commits
1ff1aabfff
...
a38602ac2c
Author | SHA1 | Date | |
---|---|---|---|
|
a38602ac2c | ||
|
26f99ecce3 | ||
|
da6139302d | ||
|
e5e777b844 | ||
|
41b740f649 |
@ -3,6 +3,7 @@
|
||||
[](https://github.com/drogonframework/drogon/actions)
|
||||
[](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://t.me/joinchat/_mMNGv0748ZkMDAx)
|
||||
[](https://discord.gg/3DvHY6Ewuj)
|
||||
[](https://cloud.docker.com/u/drogonframework/repository/docker/drogonframework/drogon)
|
||||
|
||||
English | [简体中文](./README.zh-CN.md) | [繁體中文](./README.zh-TW.md)
|
||||
|
@ -3,6 +3,7 @@
|
||||
[](https://github.com/drogonframework/drogon/actions)
|
||||
[](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://t.me/joinchat/_mMNGv0748ZkMDAx)
|
||||
[](https://discord.gg/3DvHY6Ewuj)
|
||||
[](https://cloud.docker.com/u/drogonframework/repository/docker/drogonframework/drogon)
|
||||
|
||||
[English](./README.md) | 简体中文 | [繁體中文](./README.zh-TW.md)
|
||||
|
@ -3,6 +3,7 @@
|
||||
[](https://github.com/drogonframework/drogon/actions)
|
||||
[](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://t.me/joinchat/_mMNGv0748ZkMDAx)
|
||||
[](https://discord.gg/3DvHY6Ewuj)
|
||||
[](https://cloud.docker.com/u/drogonframework/repository/docker/drogonframework/drogon)
|
||||
|
||||
[English](./README.md) | [简体中文](./README.zh-CN.md) | 繁體中文
|
||||
|
@ -1,7 +1,10 @@
|
||||
#include "Http2Transport.h"
|
||||
#include "HttpFileUploadRequest.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
|
||||
using namespace drogon;
|
||||
@ -25,6 +28,13 @@ static std::optional<size_t> stosz(const std::string &str)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Enum>
|
||||
constexpr size_t enumMaxValue()
|
||||
{
|
||||
using Underlying = std::underlying_type_t<Enum>;
|
||||
return (std::numeric_limits<Underlying>::max)();
|
||||
}
|
||||
|
||||
enum class H2FrameType
|
||||
{
|
||||
Data = 0x0,
|
||||
@ -289,13 +299,13 @@ std::optional<DataFrame> DataFrame::parse(ByteStream &payload, uint8_t flags)
|
||||
}
|
||||
|
||||
assert(payload.remaining() >= frame.padLength);
|
||||
size_t payloadSize = payload.remaining() - frame.padLength;
|
||||
if (payloadSize < 0)
|
||||
if (payload.remaining() > frame.padLength)
|
||||
{
|
||||
LOG_TRACE << "data padding is larger than the payload size";
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const size_t payloadSize = payload.remaining() - frame.padLength;
|
||||
if (payloadSize > 0x7fffffff)
|
||||
{
|
||||
LOG_ERROR << "data frame payload size too large";
|
||||
@ -836,6 +846,7 @@ void Http2Transport::onRecvMessage(const trantor::TcpConnectionPtr &,
|
||||
}
|
||||
// TODO: Should be half-closed but trantor doesn't support it
|
||||
connPtr->shutdown();
|
||||
return;
|
||||
}
|
||||
else if (std::holds_alternative<PingFrame>(frame))
|
||||
{
|
||||
@ -1062,7 +1073,7 @@ bool Http2Transport::parseAndApplyHeaders(internal::H2Stream &stream,
|
||||
else if (key == ":status")
|
||||
{
|
||||
auto status = stosz(value);
|
||||
if (!status)
|
||||
if (!status || *status > enumMaxValue<HttpStatusCode>())
|
||||
{
|
||||
streamErrored(streamId, ReqResult::BadResponse);
|
||||
return false;
|
||||
@ -1094,7 +1105,7 @@ Http2Transport::Http2Transport(trantor::TcpConnectionPtr connPtr,
|
||||
if (!connPtr->connected())
|
||||
return;
|
||||
// Send HTTP/2 magic string
|
||||
connPtr->send(h2_preamble.data(), h2_preamble.length());
|
||||
batchedSendBuffer.write(h2_preamble);
|
||||
*bytesSent_ += h2_preamble.length();
|
||||
|
||||
// RFC 9113 3.4
|
||||
@ -1103,6 +1114,7 @@ Http2Transport::Http2Transport(trantor::TcpConnectionPtr connPtr,
|
||||
settingsFrame.settings.emplace_back((uint16_t)H2SettingsKey::EnablePush,
|
||||
0); // Disable push
|
||||
sendFrame(settingsFrame, 0);
|
||||
sendBufferedData();
|
||||
}
|
||||
|
||||
void Http2Transport::handleFrameForStream(const internal::H2Frame &frame,
|
||||
|
@ -5,6 +5,7 @@
|
||||
// TODO: Write our own HPACK implementation
|
||||
#include "hpack/HPacker.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <variant>
|
||||
#include <climits>
|
||||
|
||||
@ -154,6 +155,11 @@ struct OByteStream
|
||||
buffer.append((char *)ptr, size);
|
||||
}
|
||||
|
||||
void write(const std::string_view &str)
|
||||
{
|
||||
buffer.append(str.data(), str.size());
|
||||
}
|
||||
|
||||
void overwriteU24BE(size_t offset, uint32_t value)
|
||||
{
|
||||
assert(value <= 0xffffff);
|
||||
|
Loading…
x
Reference in New Issue
Block a user