mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-15 06:32:31 +00:00
Added support for gzip accepted_encoding in scgi headers.
This commit is contained in:
+22
-9
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <torrent/event.h>
|
||||
|
||||
namespace rpc {
|
||||
@@ -11,9 +12,9 @@ class SCgi;
|
||||
|
||||
class SCgiTask : public torrent::Event {
|
||||
public:
|
||||
static const unsigned int default_buffer_size = 2047;
|
||||
static const int max_header_size = 2000;
|
||||
static const int max_content_size = (2 << 23);
|
||||
static constexpr int default_buffer_size = 8191;
|
||||
static constexpr int max_header_size = 2000;
|
||||
static constexpr int max_content_size = (2 << 23);
|
||||
|
||||
enum ContentType { XML, JSON };
|
||||
|
||||
@@ -36,23 +37,35 @@ public:
|
||||
void event_error() override;
|
||||
|
||||
private:
|
||||
static constexpr char header_xml[] = "Status: 200 OK\r\nContent-Type: text/xml\r\nContent-Length: ";
|
||||
static constexpr char header_json[] = "Status: 200 OK\r\nContent-Type: application/json\r\nContent-Length: ";
|
||||
static constexpr char header_last[] = "\r\n\r\n";
|
||||
|
||||
static constexpr size_t header_xml_size = sizeof(header_xml) - 1;
|
||||
static constexpr size_t header_json_size = sizeof(header_json) - 1;
|
||||
static constexpr size_t header_last_size = sizeof(header_last) - 1;
|
||||
|
||||
bool parse_headers(const char* current, unsigned int header_length);
|
||||
bool detect_content_type(const std::string& content_type);
|
||||
void realloc_buffer(uint32_t size, const char* buffer, uint32_t bufferSize);
|
||||
|
||||
void receive_call(const char* buffer, uint32_t length);
|
||||
void receive_write(const char* buffer, uint32_t length);
|
||||
|
||||
void plaintext_response(const char* buffer, uint32_t content_length);
|
||||
void gzip_response(const char* buffer, uint32_t content_length);
|
||||
|
||||
SCgi* m_parent{};
|
||||
|
||||
std::mutex m_result_mutex;
|
||||
|
||||
std::unique_ptr<char[]> m_buffer;
|
||||
char* m_position{};
|
||||
char* m_body{};
|
||||
std::vector<char> m_buffer;
|
||||
unsigned int m_position{};
|
||||
unsigned int m_body{};
|
||||
|
||||
unsigned int m_buffer_size{0};
|
||||
unsigned int m_content_length{};
|
||||
ContentType m_content_type{XML};
|
||||
|
||||
ContentType m_content_type{ XML };
|
||||
bool m_accepts_compression{};
|
||||
bool m_trusted{true};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user