Skip to content

Commit 1e907e9

Browse files
chungthuangjcsf
authored andcommitted
TUN-9910: Make the metadata key to carry HTTP status over QUIC transport a constant
1 parent 18eab58 commit 1e907e9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

connection/quic_connection.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const (
3333
HTTPMethodKey = "HttpMethod"
3434
// HTTPHostKey is used to get or set http host in QUIC ALPN if the underlying proxy connection type is HTTP.
3535
HTTPHostKey = "HttpHost"
36+
// HTTPStatus is used to return http status code in QUIC ALPN if the underlying proxy connection type is HTTP.
37+
HTTPStatus = "HttpStatus"
3638

3739
QUICMetadataFlowID = "FlowID"
3840
)
@@ -287,7 +289,7 @@ func (hrw *httpResponseAdapter) AddTrailer(trailerName, trailerValue string) {
287289

288290
func (hrw *httpResponseAdapter) WriteRespHeaders(status int, header http.Header) error {
289291
metadata := make([]pogs.Metadata, 0)
290-
metadata = append(metadata, pogs.Metadata{Key: "HttpStatus", Val: strconv.Itoa(status)})
292+
metadata = append(metadata, pogs.Metadata{Key: HTTPStatus, Val: strconv.Itoa(status)})
291293
for k, vv := range header {
292294
for _, v := range vv {
293295
httpHeaderKey := fmt.Sprintf("%s:%s", HTTPHeaderKey, k)
@@ -327,7 +329,7 @@ func (hrw *httpResponseAdapter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
327329
}
328330

329331
func (hrw *httpResponseAdapter) WriteErrorResponse(err error) {
330-
_ = hrw.WriteConnectResponseData(err, pogs.Metadata{Key: "HttpStatus", Val: strconv.Itoa(http.StatusBadGateway)})
332+
_ = hrw.WriteConnectResponseData(err, pogs.Metadata{Key: HTTPStatus, Val: strconv.Itoa(http.StatusBadGateway)})
331333
}
332334

333335
func (hrw *httpResponseAdapter) WriteConnectResponseData(respErr error, metadata ...pogs.Metadata) error {

0 commit comments

Comments
 (0)