Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of paths which start with a / #349

Open
jeantil opened this issue Oct 21, 2020 · 0 comments
Open

Incorrect handling of paths which start with a / #349

jeantil opened this issue Oct 21, 2020 · 0 comments

Comments

@jeantil
Copy link

jeantil commented Oct 21, 2020

I have updated the sample in #345 to add the ability to log http requests.

According to the documentation object names must adhere to some rules but may start with a /
While I don't expect this project to fully follow the naming rules in the documentation, incorrect handling of paths which start with a / is problematic because such paths are used as exemples in the documentation (such as /europe/france/paris.jpg) which can be a bad experience for begginers.

below are HTTP traces for both cases

  • writing europe/france/paris.jpg ✔️
POST /upload/storage/v1/b/bucket_1603295698243689564/o?uploadType=multipart&name=europe%2Ffrance%2Fparis.jpg
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
content-type: multipart/related; boundary=1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03
accept: */*
accept-encoding: gzip,deflate
host: 127.0.0.1:4443
--1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03
Content-Type: application/json

{"contentType":"image/jpeg"}
--1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03
Content-Type: image/jpeg

fake-gcs-server is awesome
--1a1f5d37-cb92-4c2a-9d46-5d3b17f45c03--

HTTP/1.1 200
date: Wed, 21 Oct 2020 15:54:58 GMT
content-length: 357
content-type: text/plain; charset=utf-8
{"name":"europe/france/paris.jpg","contentType":"image/jpeg","contentEncoding":"","crc32c":"qHNz6Q==","md5Hash":"nBHYLqMw7b5xFMag+TA1/Q==","acl":[{"Entity":"projectOwner","EntityID":"","Role":"OWNER","Domain":"","Email":"","ProjectTeam":null}],"created":"2020-10-21T15:54:58.30484Z","updated":"2020-10-21T15:54:58.304845Z","deleted":"0001-01-01T00:00:00Z"}
  • reading europe/france/paris.jpg ✔️
GET /storage/v1/b/bucket_1603295698243689564/o/europe%2Ffrance%2Fparis.jpg?alt=media
accept-encoding: gzip
cache-control: no-store
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
accept: */*
connection: close
host: 127.0.0.1:4443

HTTP/1.1 200
accept-ranges: bytes
content-length: 26
content-type: image/jpeg
last-modified: Wed, 21 Oct 2020 15:54:58 GMT
x-goog-generation: 0
date: Wed, 21 Oct 2020 15:54:58 GMT
connection: close
fake-gcs-server is awesome
  • writing /europe/france/paris.jpg ✔️
OST /upload/storage/v1/b/bucket_1603295793089694316/o?uploadType=multipart&name=%2Feurope%2Ffrance%2Fparis.jpg
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
content-type: multipart/related; boundary=8fcb57f0-b60e-43cd-b385-ec62eef57762
accept: */*
accept-encoding: gzip,deflate
host: 127.0.0.1:4443
--8fcb57f0-b60e-43cd-b385-ec62eef57762
Content-Type: application/json

{"contentType":"image/jpeg"}
--8fcb57f0-b60e-43cd-b385-ec62eef57762
Content-Type: image/jpeg

fake-gcs-server is awesome
--8fcb57f0-b60e-43cd-b385-ec62eef57762--

HTTP/1.1 200
date: Wed, 21 Oct 2020 15:56:33 GMT
content-length: 359
content-type: text/plain; charset=utf-8
{"name":"/europe/france/paris.jpg","contentType":"image/jpeg","contentEncoding":"","crc32c":"qHNz6Q==","md5Hash":"nBHYLqMw7b5xFMag+TA1/Q==","acl":[{"Entity":"projectOwner","EntityID":"","Role":"OWNER","Domain":"","Email":"","ProjectTeam":null}],"created":"2020-10-21T15:56:33.161242Z","updated":"2020-10-21T15:56:33.161257Z","deleted":"0001-01-01T00:00:00Z"}

  • reading /europe/france/paris.jpg
GET /storage/v1/b/bucket_1603295793089694316/o/%2Feurope%2Ffrance%2Fparis.jpg?alt=media
accept-encoding: gzip
cache-control: no-store
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
accept: */*
connection: close
host: 127.0.0.1:4443

HTTP/1.1 301
location: /storage/v1/b/bucket_1603295793089694316/o/europe/france/paris.jpg?alt=media
date: Wed, 21 Oct 2020 15:56:33 GMT
content-length: 0
connection: close

GET /storage/v1/b/bucket_1603295793089694316/o/europe/france/paris.jpg?alt=media
accept-encoding: gzip
cache-control: no-store
user-agent: gcloud-node-storage/5.3.0
x-goog-api-client: gl-node/12.18.3 gccl/5.3.0
authorization: [...redacted...]
accept: */*
connection: close
host: 127.0.0.1:4443

HTTP/1.1 404
content-type: text/plain; charset=utf-8
x-content-type-options: nosniff
date: Wed, 21 Oct 2020 15:56:33 GMT
content-length: 10
connection: close
Not Found
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants