julia
julia copied to clipboard
Supporting pipelining
The server does not support pipelining. A new request may reach without receiving response from server first. Thus, it is possible that two separate requests be in single recv buffer.
I think you didn't disallow the pipelining strictly.
Although in the request_handle_body when err == OK there is a connection_disable_in(r->c);, but soon after the handle_pass have connection_enable_in(r->c);. If r->body_done is true, it will allow the new request come in.
test code:
# server side
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "<span style='color:red'>I am app 1</span>" * 10000
# client side
def test_pipelining():
fd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
fd.connect((host.encode(), port))
headers = {'Host': host, 'Connection': 'keep-alive'}
fd.send(make_raw_request('GET', '/', headers))
with open('recv.txt', 'wb') as f:
# let `handle_response` begin
d = fd.recv(1024)
# test whether the pipelining is disallow correctly
fd.send(make_raw_request('GET', '/static/', headers))
f.write(d)
read_all(fd, f)
fd.close()
result is:
r->state: 16
julia: parse.c:259: parse_request_line: Assertion `0' failed.
Although I don't understand why the result is like this...
It doesn't disallow pipelining, it just doesn't support it. I guess I did make the assumption that the browser won't use pipelining then. I will check the parse error soon.