From 677bb9ada2594640a7c110e8d9eea64a3b281f98 Mon Sep 17 00:00:00 2001 From: Carl Hill-Popper Date: Fri, 17 Oct 2014 15:44:50 -0500 Subject: [PATCH 1/2] Update README with response file format examples --- README.md | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f1a137..028c157 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,53 @@ A url protocol that parses and returns fake responses with mock data. Create a folder reference called `VOKMockData`, so that the entire `VOKMockData` directory is copied into your test app bundle and place mock data files in there. The easiest way to determine the proper file name for a mock data item is to make the mock API call and note the missing mock data file reported in the logs. Mock data files may: - have the `.json` extension to always return an `HTTP/1.1 200 Success` with `Content-type: text/json` and the content of the `.json` file; or -- have the `.http` extension to parse a full HTTP response including status, headers, and body from the file. \ No newline at end of file +- have the `.http` extension to parse an HTTP response with the following format: + - status on the first line + - headers on the following lines (or a blank line for no headers) + - blank line + - body on the following lines (or another blank line for no body) + +Example HTTP responses: + +HTTP response with headers and response body. +``` +HTTP/1.1 201 CREATED +Server: nginx/1.4.6 (Ubuntu) +Date: Thu, 02 Oct 2014 20:50:29 GMT +Content-Type: application/json +Transfer-Encoding: chunked +Connection: keep-alive +Vary: Accept, Cookie +X-Frame-Options: SAMEORIGIN +Allow: POST, OPTIONS + +{"id": 63, "auth_token": "50db3356e743fa3f1b790a8648fc15cc4bbf04a2", "phone_number": "+13125551214", "email": "test33@test.com", "name": "Testy McTesterson", "role": "Customer"} +``` + +HTTP response with headers and no body. Note the __two__ blank lines at the end! +``` +HTTP/1.1 202 Accepted +Content-Type: text/plain; charset=UTF-8 +Date: Fri, 17 Oct 2014 14:12:46 GMT +Server: Apache-Coyote/1.1 +Content-Length: 0 +Connection: keep-alive + + +``` + +HTTP response with no headers and no body. Note the __three__ blank lines at the end! +``` +HTTP/1.1 202 Accepted + + + +``` + +HTTP response with no headers and a body. Note the __two__ blank lines in the middle! +``` +HTTP/1.1 202 Accepted + + +{"favorite_dog_breed": "dogfish"} +``` From b6f014aa95a57b9cec9db65ab049f6aae20634f1 Mon Sep 17 00:00:00 2001 From: Carl Hill-Popper Date: Tue, 28 Oct 2014 12:34:16 -0500 Subject: [PATCH 2/2] Update README.md updated to be correct with the HTTP spec --- README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 028c157..a42bb73 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ Create a folder reference called `VOKMockData`, so that the entire `VOKMockData` - have the `.json` extension to always return an `HTTP/1.1 200 Success` with `Content-type: text/json` and the content of the `.json` file; or - have the `.http` extension to parse an HTTP response with the following format: - status on the first line - - headers on the following lines (or a blank line for no headers) + - headers on the following lines - blank line - - body on the following lines (or another blank line for no body) + - body on the following lines Example HTTP responses: @@ -31,7 +31,7 @@ Allow: POST, OPTIONS {"id": 63, "auth_token": "50db3356e743fa3f1b790a8648fc15cc4bbf04a2", "phone_number": "+13125551214", "email": "test33@test.com", "name": "Testy McTesterson", "role": "Customer"} ``` -HTTP response with headers and no body. Note the __two__ blank lines at the end! +HTTP response with headers and no body. Note the blank line at the end! ``` HTTP/1.1 202 Accepted Content-Type: text/plain; charset=UTF-8 @@ -40,21 +40,17 @@ Server: Apache-Coyote/1.1 Content-Length: 0 Connection: keep-alive - ``` -HTTP response with no headers and no body. Note the __three__ blank lines at the end! +HTTP response with no headers and no body. Note the blank line at the end! ``` HTTP/1.1 202 Accepted - - ``` -HTTP response with no headers and a body. Note the __two__ blank lines in the middle! +HTTP response with no headers and a body. ``` HTTP/1.1 202 Accepted - {"favorite_dog_breed": "dogfish"} ```