Commit 786653e
committed
fix: keep the endpoint path out of the Host header
`Region::Custom` accepts an endpoint that carries a path, and `Region::host`
keeps that path so `Bucket::url` can place the bucket and key underneath it.
`host_header` returned the same string, so the path travelled in the `Host`
header as well:
PUT /storage/v1/s3/media/0000.bin HTTP/1.1
host: project.supabase.co/storage/v1/s3
RFC 9110 §7.2 defines `Host` as `uri-host [ ":" port ]`. A server that checks
answers `400 Bad Request` with no detail, which makes every request to such an
endpoint fail and says nothing about why.
Supabase Storage's S3 endpoint is `https://<project>.supabase.co/storage/v1/s3`
and is unusable for this reason: `put_object` fails before any signature is
verified. AWS, MinIO and R2 have no path in their endpoints, so nothing here
had exercised the case.
`host_header` now takes the authority and leaves `Region::host` alone, so the
request line keeps the endpoint path it needs. Verified against a Supabase
Storage bucket, where `put_object`, `head_object`, `get_object` and
`get_object_range` all succeed after the change and only the last three are
reachable before it, and against MinIO, which is unaffected.1 parent b584ce7 commit 786653e
1 file changed
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
209 | 223 | | |
210 | 224 | | |
211 | 225 | | |
| |||
291 | 305 | | |
292 | 306 | | |
293 | 307 | | |
294 | | - | |
| 308 | + | |
295 | 309 | | |
296 | 310 | | |
297 | 311 | | |
| |||
876 | 890 | | |
877 | 891 | | |
878 | 892 | | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
879 | 914 | | |
880 | 915 | | |
881 | 916 | | |
| |||
0 commit comments