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

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년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠