0

I'm trying to send some HTTP/2 data with hyper 0.7.0 as the client. The data is getting chunked into 1024 byte segments before being sent to the server (much to my chagrin). As I look through the HTTP/2 SETTINGs packets I don't see anything that would lower the size below 64 kB, which I believe to be the default for the connection and for the streams. Is there a way to know why 1024 is being chosen, and how to increase it?

I've tried:

from hyper import HTTP20Connection 
from hyper.http20.window import BaseFlowControlManager
...
class LargerWindowControlManager(BaseFlowControlManager):
    def __init__(self, *args, **kwargs):
        super().__init__(64000)
...
remote_connection = HTTP20Connection(f'{remote_node}', timeout=600)
remote_connection.network_buffer_size = 256000
...
remote_connection.request('POST', f'{path}', body=data, headers=headers, window_manager=LargerWindowControlManager)

My data is about 2557 bytes long, and this is being sent in Stream ID = 1 as three separate body fragments. While I think this should be perfectly valid, it is the only difference I can find between a working HTTP/2 POST (with curl --http2-prior-knowledge) and the failing HTTP/2 POST with hyper. When I use curl it sends the data in a single packet (of length 2557 bytes) and the server responds with success. But when I send the same data with the same headers with hyper, I get a failure (404). So I'm trying to get the data to be sent in a single packet rather than segmented across three. Any tips?

Rusty Lemur
  • 1,697
  • 1
  • 21
  • 54

1 Answers1

0

I found that this can be changed globally by changing this in the source code:

hyper-0.7.0/hyper/http20/stream.py:MAX_CHUNK = 1024

I don't know if it can be changed on a per-connection or per-session basis. And for some reason I still get the 404 error from the server even when I send it in a large chunk like that.

The issue in the end was that hyper was sending the :Authority header with only the IP of the server. The server needed the header to contain IP:Port.

Rusty Lemur
  • 1,697
  • 1
  • 21
  • 54