Hyper not stripping Connection header field #291
Comments
@persiaAziz I'm afraid I'll need a little bit more information. Can you provide the code you're using please? |
import json
from hyper import HTTPConnection
import hyper
import argparse
def getResponseString(response):
string = "HTTP/2 {0}\r\n".format(response.status)
string+='date: '+response.headers.get('date')[0].decode('utf-8')+"\r\n"
string+='server: '+response.headers.get('Server')[0].decode('utf-8')+"\r\n"
return string
def makerequest(port):
hyper.tls._context = hyper.tls.init_context()
hyper.tls._context.check_hostname = False
hyper.tls._context.verify_mode = hyper.compat.ssl.CERT_NONE
conn = HTTPConnection('localhost:443'.format(port), secure=True)
sites={'www.example.com'}
#print("port---------",port)
responses = []
request_ids = []
hdr={'Host':'www.example.com','Connection':'Keep-Alive'}
for site in sites:
request_id = conn.request('GET',url=site,headers=hdr)
request_ids.append(request_id)
# get responses
for req_id in request_ids:
response = conn.get_response(req_id)
print(getResponseString(response))
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--port","-p",
type=int,
help="Port to use")
args=parser.parse_args()
makerequest(args.port)
if __name__ == '__main__':
main() |
You can reproduce the issue with the above code. It is the Connection field in the header that causes the issue. |
@persiaAziz Do you get an exception in this code? I suspect you will. |
Yes I do @Lukasa it tells me 'stream forcefully closed' as I try to read the response |
Can you print the full stdout? |
`python3.5 h2client.py -p 443 Traceback (most recent call last): |
Hrm. Can you run |
hmm now It actually complains about that field
|
Yup, that's what I thought. So, the |
Just a bit more information on this. I upgraded to h2==2.5.0 today and my code using the I was originally going to suggest patching the adapter, but after reading through this it looks like it's a somewhat more pervasive issue. I believe what you're suggesting is stripping the 'Connection' header on all HTTP/2 connections if encountered, rather than raising an exception. Is that correct @Lukasa? I'd be willing to take a swing at this if no one else has started work on it. |
That's exactly what I'm suggesting. I'm happy for you to take a swing at it. |
This should now be resolved python-hyper/h2#382 on the master branch and available in hyper-h2's next release (2.6.0). |
How to work around it? |
@hupantingxue The easiest thing to do is just to install from the development branch for now. |
as explained in python-hyper/hyper#291
Hyper sends TCP-FIN to the latest build of apache traffic server right after sending the request data if I mention 'Connection':'Keep-Alive' in my request header.
The text was updated successfully, but these errors were encountered: