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

已提问 4 年前797 查看次数
2 回答
0
已接受的回答

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
已回答 4 年前
0

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

已回答 4 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则