-1

In python:

the http/1.1 request header is :

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

request_header = 'GET {} HTTP/1.1\r\nhost: {}\r\nConnection: close\r\n' \
          'Accept-Encoding: gzip,deflate\r\n\r\n'.format(path, host)

s = s.send(request_header.encode())

In my question is , what does the http/2 request_header like?

anyone can help me !! thanks

I've been looking at a lot of resources, but there are no examples of how to create HTTP/2 requests using sockets

Yin Lei
  • 51
  • 4
  • 1
    The part about sockets is superfluous. A socket just sends arbitrary bytes from one end to another. It doesn't care what those bytes are. Your question is how to format an HTTP/2 request; you can read the specification here: https://datatracker.ietf.org/doc/html/rfc7540 – Iguananaut Nov 15 '22 at 14:06

1 Answers1

0

Well if you are interested in stable implementation you could take a look at h2. They have an example on plain sockets. If you are interested in educational purposes poke around with tcpdump / wireshark (wshrk http2 wiki page). So you can read how the actual communication looks like in a propper tool, and implement your own version based on the example.