mirror of
https://github.com/games-on-whales/LXC2Docker.git
synced 2026-10-15 21:02:07 +00:00
[PR #103] [MERGED] fix(attach,logs): correct hijack status code and multiplexed Content-Type #103
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
games-on-whales/LXC2Docker#103
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/games-on-whales/LXC2Docker/pull/103
Author: @JBailes
Created: 7/1/2026
Status: ✅ Merged
Merged: 7/1/2026
Merged by: @JBailes
Base:
main← Head:fix/attach-hijack-response-parity📝 Commits (1)
279c42efix(attach,logs): correct hijack status code and multiplexed Content-Type📊 Changes
2 files changed (+116 additions, -14 deletions)
View changed files
➕
internal/api/attach_response_test.go(+68 -0)📝
internal/api/containers.go(+48 -14)📄 Description
Two Docker response-parity fixes surfaced by the roundtable review of #101, in the attach/logs stream handlers.
1. Attach: 200 vs 101
POST /containers/{id}/attachwroteHTTP/1.1 101 UPGRADEDunconditionally. Real Docker only sends101when the client requested a protocol upgrade (anUpgraderequest header); every other client gets the attached stream over a plain200 OK. Returning101to a non-upgrading client breaks it — the exact failure the exec-start handler already fixed in #98 (e.g. Wolf's fake-udev exec). This mirrors that logic onto attach.2. Attach + logs: multiplexed Content-Type
Both handlers advertised
Content-Type: application/vnd.docker.raw-streamunconditionally. Since Docker API v1.42 a non-TTY (stdcopy-multiplexed) stream isapplication/vnd.docker.multiplexed-stream; only a TTY stream israw-stream. The stream body was already framed correctly per-TTY (#101) — this makes the advertised media type match, so a client can tell whether to strip the 8-byte frame headers.Implementation
writeHijackPreamble(w, upgrade, tty)andstreamContentType(tty)helpers.logsContent-Type sites usestreamContentType.rec/ttymoved above the hijack so the preamble can depend on it.Tests
internal/api/attach_response_test.go—streamContentTypefor both TTY states, andwriteHijackPreambleacross all upgrade×tty combinations (status line, Content-Type, and presence/absence of Connection/Upgrade headers).Full
go test ./...,go vet,gofmtclean locally.Follow-up (not in this PR): exec-start still advertises
raw-streamfor non-TTY exec — same helper can be applied there.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.