Skip to content

Commit

Permalink
Merge pull request #21979 from chilikk/fix-exec-headers
Browse files Browse the repository at this point in the history
fix invalid HTTP header values when hijacking a connection
  • Loading branch information
openshift-merge-bot[bot] authored Mar 14, 2024
2 parents 5067f0f + 2ff5716 commit f5abca4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libpod/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func writeHijackHeader(r *http.Request, conn io.Writer, tty bool) {
// Upgraded
fmt.Fprintf(conn,
"HTTP/1.1 101 UPGRADED\r\nContent-Type: %s\r\nConnection: Upgrade\r\nUpgrade: %s\r\n\r\n",
proto, header)
header, proto)
}
}

Expand Down
5 changes: 5 additions & 0 deletions test/apiv2/20-containers.at
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ t POST "/v4.7.0/libpod/containers/foo/attach?logs=true&stream=false" 200
response_headers=$(cat "$WORKDIR/curl.headers.out")
like "$response_headers" ".*Content-Type: application/vnd\.docker\.multiplexed-stream.*" "vnd.docker.multiplexed-stream libpod v4.7.0"

t POST "containers/foo/attach?logs=true&stream=false" 101
response_headers=$(cat "$WORKDIR/curl.headers.out")
like "$response_headers" ".*Content-Type: application/vnd\.docker\.raw-stream.*" "hijacked connection header: Content-type: application/vnd.docker.raw-stream"
like "$response_headers" ".*Upgrade: tcp.*" "hijacked connection header: Upgrade: tcp"

t POST "containers/foo/kill" 204

podman run --replace --name=foo -v /tmp:/tmp $IMAGE true
Expand Down
4 changes: 4 additions & 0 deletions test/apiv2/test-apiv2
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ function t() {

local expected_code=$1; shift

if [[ "$expected_code" == "101" ]]; then
curl_args+=("-H" "Connection: upgrade" "-H" "Upgrade: tcp")
fi

# Log every action we do
echo "-------------------------------------------------------------" >>$LOG
echo "\$ $testname" >>$LOG
Expand Down

0 comments on commit f5abca4

Please sign in to comment.