HTTP 2.0

WSO2 API Microgateway is upgraded to support HTTP 2.0 (HTTP/2) together with HTTP/1.1 as the incoming and outgoing transport protocol. WSO2 API Microgateway is able to process requests faster and simpler with HTTP/2 enabled. For more information on HTTP/2 and its benefits, refer to the HTTP/2 homepage .

WSO2 API Microgateway, when configured to communicate on HTTP2, is able to switch protocols from  HTTP/1.1 to HTTP/2 and vice versa.

Identifying a HTTP 2.0 connection

A HTTP/2 request contains three special headers “ Connection ”, “ Upgrade ” and “ HTTP2-Settings ”.

upgrade: h2c
HTTP2-Settings: AAEAABAAAAIAAAABAAN_____AAQAAP__AAUAAEAAAAYAACAA
connection: HTTP2-Settings,upgrade  

A HTTP/2 response contains 3 special headers “ Connection ”, “ Upgrade ” and  "HTTP/1.1 101 Switching Protocols"

HTTP/1.1 101 Switching Protocols
connection: upgrade
upgrade: h2c

Enabling HTTP 2.0 on API Microgateway

Locate the [http2] tag in micro-gw.conf file and change the enabled value to true.

[http2]
enable=true

How it works

The following user stories explain how the API Microgateway works when HTTP/2 is enabled.

Note

  • The backend service in the following scenarios communicate on HTTP/2 without SSL.
  • The WSO2 API Microgateway server in the following scenarios communicate on HTTP/2 with SSL.
  • "h2" in the following images refers to HTTP/2.
User story 1 - Both client and backend supports HTTP 2.0

  • The user sends an HTTP/2 request to WSO2 API Microgateway.

  • WSO2 API Microgateway forwards the received HTTP/2 request to the backend as an HTTP/1.1 request after including the HTTP/2 headers to determine the protocol of the connection between WSO2 API Microgateway and the backend.

  • The backend accepts the request and sends a response back to WSO2 API Microgateway with the connection upgrade header as well as the "HTTP/1.1 101 Switching Protocols" header. This indicates that the backend supports HTTP/2. As a result, a HTTP/2 connection between WSO2 API Microgateway and the backend is established.

  • The backend sends an HTTP/2 response with the payload back WSO2 API Microgateway.

  • The Microgateway forwards that HTTP/2 response back to the client.

User story 2 - The client supports HTTP 2.0 but the backend does not support HTTP 2.0

  • The user sends an HTTP/2 request to WSO2 API Microgateway.

  • WSO2 API Microgateway forwards the received HTTP/2 request to the backend as an HTTP/1.1 request after including the HTTP/2 headers to determine the protocol of the connection between the API Microgateway and the backend.

  • Since the backend does not support the HTTP/2, it does not upgrade the connection into HTTP/2.

  • The backend sends an HTTP/1.1 response with the payload to WSO2 API Microgateway.

  • WSO2 API Microgateway then upgrades it to an HTTP/2 response by adding HTTP/2 headers and sends it to the client.

User story 3 - The client does not support HTTP/2 but the backend supports HTTP 2.0

  • The user sends an HTTP/1.1 request to WSO2 API Microgateway.

  • WSO2 API Microgateway sends the request as an HTTP/1.1 request after including the HTTP/2 headers to determine the protocol of the connection between WSO2 API Microgateway and the backend.

  • The backend accepts the request and sends a response back to the client with connection upgrade header as well as the "HTTP/1.1 101 Switching Protocols" header. This indicates that the backend supports HTTP/2. As a result, a HTTP/2 connection between WSO2 API Microgateway and the backend is established.

  • The backend sends an HTTP/2 response with the payload to the API Microgateway.

  • WSO2 API Microgateway upon receiving an HTTP/2 response, proceeds to downgrade the response to an HTTP/1.1 response removing the HTTP/2  headers and forwards it to the client.

Top