Skip to content

Commit 64fdafc

Browse files
committed
bubble content-type handling up so that it can be assumed througouth
1 parent 847b2bd commit 64fdafc

File tree

1 file changed

+55
-66
lines changed

1 file changed

+55
-66
lines changed

peps/pep-0694.rst

Lines changed: 55 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,52 @@ PEP does not modify the legacy API in any way.
173173

174174
The API proposed in this PEP therefor has the version number ``2.0``.
175175

176+
Content Types
177+
-------------
178+
179+
Like :pep:`691`, this PEP proposes that all requests and responses from this upload API will have a
180+
standard content type that describes what the content is, what version of the API it represents, and
181+
what serialization format has been used.
182+
183+
This standard request content type applies to all requests *except* for requests to execute
184+
a File Upload Mechanism, which will be specified by the documentation for that mechanism.
185+
186+
The structure of the ``Content-Type`` header for all other requests is:
187+
188+
.. code-block:: text
189+
190+
application/vnd.pypi.upload.$version+$format
191+
192+
Since minor API version differences should never be disruptive, only the major version is included
193+
in the content type; the version number is prefixed with a ``v``.
194+
195+
The major API version specified in the ``.meta.api-version`` JSON key of client requests
196+
**MUST** match the ``Content-Type`` header for major version.
197+
198+
Unlike :pep:`691`, this PEP does not change the existing *legacy* ``1.0`` upload API in any way, so
199+
servers are required to host the new API described in this PEP at a different endpoint than the
200+
existing upload API.
201+
202+
Since JSON is the only defined request format defined in this PEP, all non-file-upload requests
203+
defined in this PEP **MUST** include a ``Content-Type`` header value of:
204+
205+
- ``application/vnd.pypi.upload.v2+json``.
206+
207+
Similar to :pep:`691`, this PEP also standardizes on using server-driven content negotiation to
208+
allow clients to request different versions or serialization formats, which includes the ``format``
209+
part of the content type. However, since this PEP expects the existing legacy ``1.0`` upload API to
210+
exist at a different endpoint, and this PEP currently only provides for JSON serialization, this
211+
mechanism is not particularly useful. Clients only have a single version and serialization they can
212+
request. However clients **SHOULD** be prepared to handle content negotiation gracefully in the case
213+
that additional formats or versions are added in the future.
214+
215+
Unless otherwise specified, all HTTP requests and responses in this document are assumed to include
216+
the HTTP header:
217+
218+
.. code-block:: text
219+
220+
Content-Type: application/vnd.pypi.upload.v2+json
221+
176222
177223
Root Endpoint
178224
-------------
@@ -191,9 +237,7 @@ Create an Upload Session
191237
A release starts by creating a new upload session. To create the session, a client submits a
192238
``POST`` request to the root URL like:
193239

194-
.. code-block:: text
195-
196-
Content-Type: application/vnd.pypi.upload.v2+json
240+
.. code-block:: json
197241
198242
{
199243
"meta": {
@@ -244,9 +288,7 @@ Response Body
244288

245289
The successful response includes the following content:
246290

247-
.. code-block:: text
248-
249-
Content-Type: application/vnd.pypi.upload.v2+json
291+
.. code-block:: json
250292
251293
{
252294
"meta": {
@@ -375,9 +417,7 @@ to those URLs from one session to the next.
375417
To initiate a file upload, a client first sends a ``POST`` request to the ``upload`` URL. The
376418
request looks like:
377419

378-
.. code-block:: text
379-
380-
Content-Type: application/vnd.pypi.upload.v2+json
420+
.. code-block:: json
381421
382422
{
383423
"meta": {
@@ -442,9 +482,7 @@ File Upload Session Response Body
442482

443483
The successful response includes the following:
444484

445-
.. code-block:: text
446-
447-
Content-Type: application/vnd.pypi.upload.v2+json
485+
.. code-block:: json
448486
449487
{
450488
"meta": {
@@ -460,8 +498,7 @@ The successful response includes the following:
460498
"http-post-application-octet-stream": {
461499
"file_url": "..."
462500
"attestations_url": "..."
463-
},
464-
...
501+
}
465502
}
466503
}
467504
@@ -505,9 +542,7 @@ file upload session creation response body.
505542

506543
The requests looks like:
507544

508-
.. code-block:: text
509-
510-
Content-Type: application/vnd.pypi.upload.v2+json
545+
.. code-block:: json
511546
512547
{
513548
"meta": {
@@ -588,9 +623,7 @@ or :ref:`file upload session creation response body <file-upload-session-respons
588623

589624
The request looks like:
590625

591-
.. code-block:: text
592-
593-
Content-Type: application/vnd.pypi.upload.v2+json
626+
.. code-block:: json
594627
595628
{
596629
"meta": {
@@ -640,9 +673,7 @@ response body <session-response>`.
640673

641674
The request looks like:
642675

643-
.. code-block:: text
644-
645-
Content-Type: application/vnd.pypi.upload.v2+json
676+
.. code-block:: json
646677
647678
{
648679
"meta": {
@@ -737,9 +768,7 @@ Errors
737768

738769
All error responses that contain content look like:
739770

740-
.. code-block:: text
741-
742-
Content-Type: application/vnd.pypi.upload.v2+json
771+
.. code-block:: json
743772
744773
{
745774
"meta": {
@@ -834,46 +863,6 @@ containing a JSON array of :pep:`attestation objects <740#attestation-objects>`
834863
[{"version": 1, "verification_material": {...}, "envelope": {...}},...]
835864
836865
837-
Content Types
838-
-------------
839-
840-
Like :pep:`691`, this PEP proposes that all requests and responses from this upload API will have a
841-
standard content type that describes what the content is, what version of the API it represents, and
842-
what serialization format has been used.
843-
844-
This standard request content type applies to all requests *except* for requests to execute
845-
a File Upload Mechanism, which will be specified by the documentation for that mechanism.
846-
847-
The structure of the ``Content-Type`` header for all other requests is:
848-
849-
.. code-block:: text
850-
851-
application/vnd.pypi.upload.$version+$format
852-
853-
Since minor API version differences should never be disruptive, only the major version is included
854-
in the content type; the version number is prefixed with a ``v``.
855-
856-
The major API version specified in the ``.meta.api-version`` JSON key of client requests
857-
**MUST** match the ``Content-Type`` header for major version.
858-
859-
Unlike :pep:`691`, this PEP does not change the existing *legacy* ``1.0`` upload API in any way, so
860-
servers are required to host the new API described in this PEP at a different endpoint than the
861-
existing upload API.
862-
863-
Since JSON is the only defined request format defined in this PEP, all non-file-upload requests
864-
defined in this PEP **MUST** include a ``Content-Type`` header value of:
865-
866-
- ``application/vnd.pypi.upload.v2+json``.
867-
868-
Similar to :pep:`691`, this PEP also standardizes on using server-driven content negotiation to
869-
allow clients to request different versions or serialization formats, which includes the ``format``
870-
part of the content type. However, since this PEP expects the existing legacy ``1.0`` upload API to
871-
exist at a different endpoint, and this PEP currently only provides for JSON serialization, this
872-
mechanism is not particularly useful. Clients only have a single version and serialization they can
873-
request. However clients **SHOULD** be prepared to handle content negotiation gracefully in the case
874-
that additional formats or versions are added in the future.
875-
876-
877866
FAQ
878867
===
879868

0 commit comments

Comments
 (0)