Repository navigation
Commit 9cae1fe
fix(relay): decompress gzip-encoded git smart-HTTP request bodies
git's smart-HTTP client gzip-compresses the git-upload-pack /
git-receive-pack request body once it exceeds an internal size
threshold. That threshold is driven by the number of want/have lines,
so it fires reliably on clones/fetches of repositories with many refs
(hundreds+ of branches/tags), while small repositories stay under it.
The relay pipes the request body straight into the git subprocess's
stdin, so a still-compressed body reaches `git upload-pack` as raw
gzip. git then fails parsing pkt-lines with:
fatal: protocol error: bad line length character: <binary>
Because the subprocess stderr is discarded, this surfaced to clients
only as a mid-stream "the remote end hung up unexpectedly" — with no
server-side signal — making it hard to diagnose. The symptom is
strongly ref-count-correlated (small repos clone fine, many-ref repos
always fail), which is exactly the gzip threshold crossing.
Fix: add `decode_git_request_body`, which transparently inflates the
body when `Content-Encoding: gzip` (or `x-gzip`) is present, and apply
it in both `upload_pack` and `receive_pack` before the body is streamed
to the subprocess. Identity-encoded bodies pass through byte-for-byte,
so the common small-clone path is unchanged. Only gzip is decoded (the
sole encoding git emits); an unknown non-identity encoding is passed
through rather than rejected, letting the subprocess surface any real
mismatch as an in-band protocol error.
Adds unit tests for both the gzip-inflate and identity-passthrough
paths.
Co-Authored-By: Claude Opus 4.8 <[email protected]>1 parent acfbb1b commit 9cae1fe
3 files changed
Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| 94 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
717 | 751 | | |
718 | 752 | | |
719 | 753 | | |
| |||
723 | 757 | | |
724 | 758 | | |
725 | 759 | | |
| 760 | + | |
726 | 761 | | |
727 | 762 | | |
728 | 763 | | |
729 | 764 | | |
| 765 | + | |
730 | 766 | | |
731 | 767 | | |
732 | 768 | | |
| |||
793 | 829 | | |
794 | 830 | | |
795 | 831 | | |
| 832 | + | |
796 | 833 | | |
797 | 834 | | |
798 | 835 | | |
799 | 836 | | |
| 837 | + | |
800 | 838 | | |
801 | 839 | | |
802 | 840 | | |
| |||
1694 | 1732 | | |
1695 | 1733 | | |
1696 | 1734 | | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
| 1754 | + | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
1697 | 1772 | | |
1698 | 1773 | | |
1699 | 1774 | | |
| |||
0 commit comments