Skip to content

Commit c0b15b8

Browse files
authoredNov 10, 2022
Added support chunked response body (#24)
* Fix for CVE-2015-0219 * Update submodule libuv to 1.44.2 stable * Replacing int to int64_t (content length) * Fix "Connection" header on response * Redesign wsgi_body_pleload function (detect filelike response body) * Added support for sending responses containing large files * Added support for sending chunked content (when length is unknown) * Fix incorrect parsing HTTP field values * Fix Expect: 100-continue for PycURL * Detecting and blocking HTTP pipelining * Added preallocated read buffer and new environ option
1 parent 37e772f commit c0b15b8

11 files changed

+363
-121
lines changed
 

‎fastwsgi/common.c

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "common.h"
2+
#include "llhttp.h"
23

34
void logrepr(int level, PyObject* obj)
45
{
@@ -10,6 +11,17 @@ void logrepr(int level, PyObject* obj)
1011
Py_XDECREF(str);
1112
}
1213

14+
const char * get_http_status_name(int status)
15+
{
16+
#define HTTP_STATUS_GEN(NUM, NAME, STRING) case HTTP_STATUS_##NAME: return #STRING;
17+
switch (status) {
18+
HTTP_STATUS_MAP(HTTP_STATUS_GEN)
19+
default: return NULL;
20+
}
21+
#undef HTTP_STATUS_GEN
22+
return NULL;
23+
}
24+
1325
int64_t get_env_int(const char * name)
1426
{
1527
int64_t v;

‎fastwsgi/common.h

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
# define INLINE inline
2020
#endif
2121

22+
#define _max(a,b) (((a) > (b)) ? (a) : (b))
23+
#define _min(a,b) (((a) < (b)) ? (a) : (b))
24+
2225
typedef union {
2326
struct sockaddr_storage storage;
2427
struct sockaddr addr;
@@ -46,4 +49,6 @@ void logrepr(int level, PyObject * obj);
4649

4750
int64_t get_env_int(const char * name);
4851

52+
const char * get_http_status_name(int status);
53+
4954
#endif

‎fastwsgi/constants.c

+3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ void init_constants() {
3333

3434
g_cv.module_io = PyImport_ImportModule("io");
3535
g_cv.BytesIO = PyUnicode_FromString("BytesIO");
36+
g_cv.close = PyUnicode_FromString("close");
3637
g_cv.write = PyUnicode_FromString("write");
3738
g_cv.read = PyUnicode_FromString("read");
3839
g_cv.truncate = PyUnicode_FromString("truncate");
3940
g_cv.seek = PyUnicode_FromString("seek");
41+
g_cv.tell = PyUnicode_FromString("tell");
42+
g_cv.buffer_size = PyUnicode_FromString("buffer_size");
4043
g_cv.getvalue = PyUnicode_FromString("getvalue");
4144
g_cv.comma = PyUnicode_FromString(",");
4245

‎fastwsgi/constants.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ typedef struct {
3434

3535
PyObject* module_io;
3636
PyObject* BytesIO;
37+
PyObject* close;
3738
PyObject* write;
3839
PyObject* read;
3940
PyObject* truncate;
4041
PyObject* seek;
42+
PyObject* tell;
43+
PyObject* buffer_size;
4144
PyObject* getvalue;
4245
PyObject* comma;
4346

0 commit comments

Comments
 (0)
Please sign in to comment.