Are HTTP/2 and HTTP/3 still a request and response based protocol?
Asked Answered
M

1

0

This RFC for HTTP/1.1 says

The HTTP protocol is a request/response protocol.

Moving to newer HTTP protocols - HTTP/2 spec says that each stream is a bidirectional sequence of frames. Both client and the server can initiate stream creation. (Although server stream creation is in response to a client request and only mentioned with regards to H2 server push which is not relevant anymore)

gRPC and Websockets are run on a single client initiated H2 stream as well. Both allows bidirectional communication.

  • Does this mean that H2 and H3 are no more request/response protocols?
  • Is a single H2 stream full duplex? (By full duplex I mean can the client and server write and read messages from a single stream at the same time. I'm not talking about H2 multiplexing here.)
  • Can the server send unsolicited messages to the client? (except for server push - since its not relevant anymore). If not, how does gRPC or Websockets bidirectional communication work over H2?
Marshamarshal answered 19/2, 2023 at 18:49 Comment(0)
T
0

Does this mean that H2 and H3 are no more request/response protocols?

They're still request/response protocols. You can build other kinds of protocols on top of that, but they're still request/response. Or you can define "request/response" in a very strict way such that HTTP/2 isn't, but then HTTP/1.1 isn't either when it's being used with BOSH. It's not a particularly meaningful designation.

Is a single H2 stream full duplex?

Yes. H2 streams are bidirectional.

Can the server send unsolicited messages to the client?

Not specifically, but that's not how WebSockets work over HTTP/2. See RFC 8441.

Thirddegree answered 19/2, 2023 at 19:18 Comment(5)
Websockets over H2 uses a tunneled stream. since websockets is bidi, for it to work over a H2 stream, the server has to be able send unsolicited H2 messages (combination of frames) to the client. Isn't this correct? Considering that H2 messages (multiple related frames) are mapped to HTTP/1.1 request/response, Isn't this implementation (WS over H2) diverging from the traditional req/res based model.Marshamarshal
WebSocket over HTTP/2 builds on a request initiated by the client that has an infinite body, along with an response from the server that has an infinite body, so the whole WebSocket communication is a single request/response for HTTP/2. The client still has to initiate the request, so the server cannot initiate any unsolicited communication unless the client has made an HTTP/2 request to upgrade to WebSocket. As such it is not diverging from traditional request/response model -- HTTP/2 does not know what's tunnelling, it's just a very long request body with a very long response body.Williams
Agreed w/ sbordet. The existence of BOSH didn't make HTTP "not request/response." That said, "request/response" is a description of the overall design of HTTP (and H2/3). There is no strict test that would perfectly distinguish "request/response" from "not request/response" any more than we can unambiguously classify object-oriented or functional programming languages. And the fact that you can use a language in a way other than its design does not change its design. These are all just words we use to get our heads around how a thing works. They're not strict rules with perfectly clean edges.Thirddegree
@Williams Yes, thinking it as "single req/res with infinite body" now makes sense (for both WS and gRPC).Marshamarshal
@RobNapier I don't think BOSH is comparable to WS on H2 stream when talking about req/res model. Since BOSH has a clear start and end to a req/res cycle whereas in case of WS it's a single infinite request and response. But I get your point. It's difficult to find perfect boundaries now since the HTTP protocol itself is evolving.Marshamarshal

© 2022 - 2024 — McMap. All rights reserved.