Implement POST method support for objects upload #6

Closed
opened 2025-12-28 17:35:44 +00:00 by sami · 0 comments
Owner

Originally created by @realloc on GitHub (Jan 21, 2021).

Uploads has to use POST method, because PUT must be idempotent. When we upload through HTTP protocol gate, the actual object created at NeoFS protocol level may have different resulting ObjectID, hence there may be different result with different side-effects and this doesn't confirm the expected PUT behaviour.

Because ObjectId can't be calculated beforehand, the URL string will contain only ContainerID string.

Object attributes should be taken from X-Attribute-* headers. If there are known sources of information for other object headers, they also must be considered. For example filename in Content-Disposition header has to be translated into Filename object attribute.

Note, that http header with underscores in names, used to distinguish well-known system attributes in NeoFS, are ignored by most of web servers because of FCGI/CGI variables naming conflicts. As a workaround, some special translation table must be used for HTTP.

Note, that HTTP header naming rules have differences with attribute naming rules in NeoFS. HTTP headers are case-insensitive and use ASCII range, according to RFC, but NeoFS attributes are case-sensitive and use any valid UTF-8 characters.

Example request:

POST /container_id HTTP/1.1
Host: send.fs.neo.org
Content-Type: multipart/form-data;boundary="boundary"
X-Attribute-NEOFS-EXPIRATION-EPOCH: 12345

--boundary
Content-Disposition: form-data; filename="example.txt"
...
--boundary--

PS: Originally posted by @realloc in https://github.com/nspcc-dev/neofs-http-gate/pull/14#issuecomment-772345689

After discussion, we decided to simplify attribute translation for now. Full translation requires support for UTF-8 values encoded according to RFC 8187/7230, this can be clarified and implemented in further PRs.

  1. Remove translation tables
  2. Use simple translation rules only, for now ignoring UTF-8 keys and values
  • X-Attribute-NEOFS- prefixed headers considered well-known system attributes
  • System Attribute key is uppercased
  • System Attribute key's - translates to _
  • X-Attribute- prefixed headers considered regular object attributes
  • Normal attribute key is a result of http header prefix trimming
  • Value string should be left as is, for now
HTTP:
X-Attribute-NEOFS-Expiration-Epoch: 123
X-Attribute-FileName: cat.jpg

NeoFS:
__NEOFS__EXPIRATION_EPOCH: "123"
FileName: "cat.jpg"
Originally created by @realloc on GitHub (Jan 21, 2021). Uploads has to use POST method, because PUT must be idempotent. When we upload through HTTP protocol gate, the actual object created at NeoFS protocol level may have different resulting ObjectID, hence there may be different result with different side-effects and this doesn't confirm the expected PUT behaviour. Because ObjectId can't be calculated beforehand, the URL string will contain only ContainerID string. Object attributes should be taken from `X-Attribute-*` headers. If there are known sources of information for other object headers, they also must be considered. For example `filename` in `Content-Disposition` header has to be translated into `Filename` object attribute. Note, that http header with underscores in names, used to distinguish well-known system attributes in NeoFS, are ignored by most of web servers because of FCGI/CGI variables naming conflicts. As a workaround, some special translation table must be used for HTTP. Note, that HTTP header naming rules have differences with attribute naming rules in NeoFS. HTTP headers are case-insensitive and use ASCII range, according to RFC, but NeoFS attributes are case-sensitive and use any valid UTF-8 characters. Example request: ``` POST /container_id HTTP/1.1 Host: send.fs.neo.org Content-Type: multipart/form-data;boundary="boundary" X-Attribute-NEOFS-EXPIRATION-EPOCH: 12345 --boundary Content-Disposition: form-data; filename="example.txt" ... --boundary-- ``` --- PS: _Originally posted by @realloc in https://github.com/nspcc-dev/neofs-http-gate/pull/14#issuecomment-772345689_ After discussion, we decided to simplify attribute translation for now. Full translation requires support for UTF-8 values encoded according to RFC 8187/7230, this can be clarified and implemented in further PRs. 1. Remove translation tables 2. Use simple translation rules only, for now ignoring UTF-8 keys and values - `X-Attribute-NEOFS-` prefixed headers considered well-known system attributes - System Attribute key is uppercased - System Attribute key's `-` translates to `_` - `X-Attribute-` prefixed headers considered regular object attributes - Normal attribute key is a result of http header prefix trimming - Value string should be left as is, for now ``` HTTP: X-Attribute-NEOFS-Expiration-Epoch: 123 X-Attribute-FileName: cat.jpg NeoFS: __NEOFS__EXPIRATION_EPOCH: "123" FileName: "cat.jpg" ```
sami 2025-12-28 17:35:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-http-gw#6
No description provided.