Klaus Demo bjoern / a2314a5
Add DBG statements Jonas Haag 2 months ago
2 changed file(s) with 9 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
4747 CFLAGS='-Os' make
4848
4949 _bjoernmodule:
50 @echo ' -> ' $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(objects) -o $(BUILD_DIR)/_bjoern.so
5051 @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(objects) -o $(BUILD_DIR)/_bjoern.so
5152 @PYTHONPATH=$$PYTHONPATH:$(BUILD_DIR) ${PYTHON} -c "import bjoern"
5253
6666 _PEP3333_Bytes_Check(PyList_GET_ITEM(retval, 0)))
6767 {
6868 /* Optimize the most common case, a single bytestring in a list: */
69 DBG_REQ(request, "WSGI iterable is list of size 1");
6970 PyObject* tmp = PyList_GET_ITEM(retval, 0);
7071 Py_INCREF(tmp);
7172 Py_DECREF(retval);
7677 * i.e. sending the response item for item. "item for item" means
7778 * "char for char" if you have a bytestring. -- I'm not that stupid. */
7879 bytestring:
80 DBG_REQ(request, "WSGI iterable is byte string");
7981 request->iterable = NULL;
8082 request->iterator = NULL;
8183 if(_PEP3333_Bytes_GET_SIZE(retval)) {
8688 first_chunk = NULL;
8789 }
8890 } else if(FileWrapper_CheckExact(retval) && FileWrapper_GetFd(retval) != -1) {
91 DBG_REQ(request, "WSGI iterable is wsgi.file_wrapper instance and Content-Length is known");
8992 request->iterable = retval;
9093 request->iterator = NULL;
9194 first_chunk = NULL;
9295 } else {
9396 /* Generic iterable (list of length != 1, generator, ...) */
97 DBG_REQ(request, "WSGI iterable is some other iterable");
9498 request->iterable = retval;
9599 request->iterator = PyObject_GetIter(retval);
96100 if(request->iterator == NULL)
124128 if(request->state.response_length_unknown) {
125129 if(request->parser.parser.http_major > 0 && request->parser.parser.http_minor > 0) {
126130 /* On HTTP 1.1, we can use Transfer-Encoding: chunked. */
131 DBG_REQ(request, "Content-Length unknown, HTTP/1.1 -> Connection: will keep-alive with chunked response");
127132 request->state.chunked_response = true;
128133 request->state.keep_alive = true;
129134 } else {
130135 /* On HTTP 1.0, we can only resort to closing the connection. */
136 DBG_REQ(request, "Content-Length unknown, HTTP/1.10 -> will close");
131137 request->state.keep_alive = false;
132138 }
133139 } else {
134140 /* We know the content-length. Can always keep-alive. */
141 DBG_REQ(request, "Content-Length known -> will keep alive");
135142 request->state.keep_alive = true;
136143 }
137144 } else {
138145 /* Explicit "Connection: close" (HTTP 1.1) or missing "Connection: keep-alive" (HTTP 1.0) */
146 DBG_REQ(request, "Connection: close request by client");
139147 request->state.keep_alive = false;
140148 }
141149