HandlePeerGet returns cached data to a peer.
(w http.ResponseWriter, r *http.Request)
| 787 | |
| 788 | // originErrorBodyCap is the maximum number of bytes we'll buffer from a |
| 789 | // non-2xx origin response. S3 XML error envelopes are tiny; this is just a |
| 790 | // safety net. |
| 791 | const originErrorBodyCap = 1 << 20 // 1 MiB |
| 792 | |
| 793 | // originStatusError captures a non-2xx response from the origin so the |
| 794 | // proxy can forward it back to the client verbatim. The status code, body, |
| 795 | // and response headers are all preserved (minus hop-by-hop) so DuckDB sees |
| 796 | // exactly what S3 said — including the XML error envelope DuckLake may |
| 797 | // inspect. |
| 798 | type originStatusError struct { |
| 799 | status int |
| 800 | headers http.Header |
| 801 | body []byte |
| 802 | } |
| 803 | |
| 804 | func (e *originStatusError) Error() string { |
| 805 | return fmt.Sprintf("origin %d: %s", e.status, strings.TrimSpace(string(e.body))) |
| 806 | } |
| 807 | |
| 808 | // writeTo replays the captured origin response onto w. Any header the origin |