Which headers can be set in a $connect route response?

0

According to this example[1], the "Sec-WebSocket-Protocol" header can be set from a Lambda function set as a proxy integration for the $connect handler of a Websocket API, by returning the following payload:

{
  statusCode: 200,
  headers: {
    "Sec-WebSocket-Protocol" : "myprotocol"
  }
}

My question is, can other headers be set as well? It seems other headers are currently stripped. For example, when I set a 'Set-Cookie' header in the response, the header does not show up in the HTTP response. Is there a way to configure the route response or integration response so that such headers appear?

[1] https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/websocket-connect-route-subprotocol.html

Edited by: "jedlie" on Jul 12, 2020 6:14 AM

Edited by: "jedlie" on Jul 12, 2020 6:25 AM

preguntada hace 4 años798 visualizaciones
2 Respuestas
0
Respuesta aceptada

No, WebSocket API doesn't allow to set other header. Most headers other than Upgrade, Connection, Sec-WebSocket-* are not meaningful for the handshake, but I do agree that Set-Cookie would be a valid use case, as mentioned in the specification.

_The server can also set cookie-related option fields to set_cookies, as described in [RFC6265].

AWS
respondido hace 4 años
0

Thanks for the reply, jwaataws. Would love to see Set-Cookie allowlisted soon for Websocket APIs.

respondido hace 4 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas