Skip to content

Commit 365cfd4

Browse files
committed
Add client section, drop clarification
Signed-off-by: William Woodruff <william@yossarian.net>
1 parent 0baf0f5 commit 365cfd4

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎source/specifications/simple-repository-api.rst‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ can be implemented in Python with the ``re`` module::
5050
Error Responses
5151
---------------
5252

53-
If a response to the simple API cannot be honored, the simple API **MUST** respond
54-
with an appropriate HTTP error code (in the range 400-499 or 500-599).
53+
Package indices
54+
~~~~~~~~~~~~~~~
5555

5656
When preparing to send an error response to a requester (e.g., an installer client),
5757
the package index **SHOULD** format its response as an
@@ -95,6 +95,23 @@ The following is an example of a Problem Details response:
9595
"instance": "https://py.example.com/ORGNAME/..."
9696
}
9797
98+
99+
Clients
100+
~~~~~~~
101+
102+
Upon receipt of an error response from an origin, the client **SHOULD**:
103+
104+
- Confirm that the ``Content-Type`` is ``application/problem+json``. If the ``Content-Type``
105+
is not ``application/problem+json``, the client **MUST NOT** process the response
106+
as if it contains a Problem Details object.
107+
- Deserialize the response body as JSON, and validate it as a Problem Details object.
108+
- Use the contents of the Problem Details object to present a contextually
109+
appropriate error message to the user.
110+
111+
If the process above fails at any step, the client **MAY** handle the original HTTP
112+
error response as it sees fit. This can include handling the error using any pre-existing,
113+
generic HTTP error handling logic.
114+
98115
.. _simple-repository-api-versioning:
99116

100117
Versioning PyPI's Simple API

0 commit comments

Comments
 (0)