Skip to content
Snippets Groups Projects
Commit 342560e8 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

Demonstrate via tests that our api deals with client's accept header

Accepted types: application/json, application/yaml, text/html

In browser, this means that our api is only browsable.

With curl (or other similar tools) however, you can ask with the Accept
headers

For example:

$ curl -v -H 'Accept:application/yaml' -X GET
http://localhost:6543/api/1/revision/edfbd9e840cc82e879d9aae8ecc29c7121ff750
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying ::1...
* connect to ::1 port 6543 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 6543 (#0)
> GET /api/1/revision/edfbd9e840cc82e879d9aae8ecc29c7121ff750 HTTP/1.1
> Host: localhost:6543
> User-Agent: curl/7.45.0
> Accept:application/yaml
>
* HTTP 1.0, assume close after body
< HTTP/1.0 400 BAD REQUEST
< Content-Type: application/yaml
< Content-Length: 39
< Server: Werkzeug/0.10.4 Python/3.4.3+
< Date: Tue, 24 Nov 2015 13:00:23 GMT
<
{error: invalid checksum query string}
* Closing connection 0

$ curl -v -H 'Accept:application/json' -X GET
http://localhost:6543/api/1/revision/edfbd9e840cc82e879d9aae8ecc29c7121ff750
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying ::1...
* connect to ::1 port 6543 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 6543 (#0)
> GET /api/1/revision/edfbd9e840cc82e879d9aae8ecc29c7121ff750 HTTP/1.1
> Host: localhost:6543
> User-Agent: curl/7.45.0
> Accept:application/json
>
* HTTP 1.0, assume close after body
< HTTP/1.0 400 BAD REQUEST
< Content-Type: application/json
< Content-Length: 42
< Server: Werkzeug/0.10.4 Python/3.4.3+
< Date: Tue, 24 Nov 2015 13:00:28 GMT
<
* Closing connection 0
{"error": "invalid checksum query string"}%
parent 401b7d6e
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment