Skip to content

Commit

Permalink
fix(persister): Only persist post data if a request has a body (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
offirgolan authored Jan 29, 2019
1 parent 62374f4 commit f62d318
Show file tree
Hide file tree
Showing 33 changed files with 397 additions and 899 deletions.
7 changes: 4 additions & 3 deletions packages/@pollyjs/persister/src/har/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ export default class Request {
this.queryString = toNVPairs(request.query);
this.cookies = setCookies.parse(request.getHeader('Set-Cookie'));

if (request.body || request.hasHeader('Content-Type')) {
if (request.body) {
this.postData = {
mimeType: request.getHeader('Content-Type') || 'text/plain'
mimeType: request.getHeader('Content-Type') || 'text/plain',
params: []
};

if (request.body && typeof request.body === 'string') {
if (typeof request.body === 'string') {
this.postData.text = request.body;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"_recordingName": "@pollyjs/adapter-fetch/Integration | Fetch Adapter | Browser/should be able to abort from an intercept",
"browser": {
"name": "Chrome",
"version": "67.0"
"version": "71.0"
},
"creator": {
"comment": "persister:rest",
"name": "Polly.JS",
"version": "0.5.0"
"version": "1.4.2"
},
"entries": [
{
Expand All @@ -23,7 +23,7 @@
"httpVersion": "HTTP/1.1",
"method": "GET",
"queryString": [],
"url": "http://localhost:7357/api/db/-pollyjs_2160168770%2Fadapter-fetch_162589637%2FIntegration-Fetch-Adapter-Browser_2847373818%2Fshould-be-able-to-abort-from-an-intercept_68559697"
"url": "http://localhost:4000/api/db/-pollyjs_2160168770%2Fadapter-fetch_162589637%2FIntegration-Fetch-Adapter-Browser_2847373818%2Fshould-be-able-to-abort-from-an-intercept_68559697"
},
"response": {
"bodySize": 0,
Expand All @@ -33,43 +33,39 @@
},
"cookies": [],
"headers": [
{
"name": "access-control-allow-origin",
"value": "*"
},
{
"name": "connection",
"value": "close"
"value": "keep-alive"
},
{
"name": "content-length",
"value": "0"
},
{
"name": "date",
"value": "Tue, 17 Jul 2018 19:58:20 GMT"
"value": "Tue, 29 Jan 2019 05:33:46 GMT"
},
{
"name": "x-powered-by",
"value": "Express"
}
],
"headersSize": 132,
"headersSize": 105,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 404,
"statusText": "Not Found"
},
"startedDateTime": "2018-07-17T19:58:20.210Z",
"time": 16,
"startedDateTime": "2019-01-29T05:33:46.877Z",
"time": 5,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 16
"wait": 5
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"_recordingName": "@pollyjs/adapter-fetch/Integration | Fetch Adapter | Browser/should call all the life-cycle events",
"browser": {
"name": "Chrome",
"version": "70.0"
"version": "71.0"
},
"creator": {
"comment": "persister:rest",
"name": "Polly.JS",
"version": "1.3.1"
"version": "1.4.2"
},
"entries": [
{
Expand Down Expand Up @@ -43,7 +43,7 @@
},
{
"name": "date",
"value": "Mon, 03 Dec 2018 19:44:11 GMT"
"value": "Tue, 29 Jan 2019 05:33:46 GMT"
},
{
"name": "x-powered-by",
Expand All @@ -56,7 +56,7 @@
"status": 404,
"statusText": "Not Found"
},
"startedDateTime": "2018-12-03T19:44:11.083Z",
"startedDateTime": "2019-01-29T05:33:46.914Z",
"time": 6,
"timings": {
"blocked": -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"_recordingName": "@pollyjs/adapter-fetch/Integration | Fetch Adapter | Browser/should handle a compressed response",
"browser": {
"name": "Chrome",
"version": "70.0"
"version": "71.0"
},
"creator": {
"comment": "persister:rest",
"name": "Polly.JS",
"version": "1.3.1"
"version": "1.4.2"
},
"entries": [
{
Expand All @@ -29,6 +29,7 @@
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"foo\":\"bar\"}"
},
"queryString": [],
Expand All @@ -53,7 +54,7 @@
},
{
"name": "date",
"value": "Mon, 03 Dec 2018 23:22:36 GMT"
"value": "Tue, 29 Jan 2019 05:33:46 GMT"
},
{
"name": "transfer-encoding",
Expand All @@ -74,16 +75,16 @@
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2018-12-03T23:22:36.596Z",
"time": 36,
"startedDateTime": "2019-01-29T05:33:46.939Z",
"time": 9,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 36
"wait": 9
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"_recordingName": "@pollyjs/adapter-fetch/Integration | Fetch Adapter | Browser/should properly handle 204 status code response",
"browser": {
"name": "Chrome",
"version": "68.0"
"version": "71.0"
},
"creator": {
"comment": "persister:rest",
"name": "Polly.JS",
"version": "1.1.3"
"version": "1.4.2"
},
"entries": [
{
Expand Down Expand Up @@ -52,33 +52,33 @@
},
{
"name": "date",
"value": "Wed, 22 Aug 2018 07:03:38 GMT"
"value": "Tue, 29 Jan 2019 05:33:46 GMT"
},
{
"name": "etag",
"value": "W/\"a-bAsFyilMr4Ra1hIU5PyoyFRunpI\""
"value": "\"a-bAsFyilMr4Ra1hIU5PyoyFRunpI\""
},
{
"name": "x-powered-by",
"value": "Express"
}
],
"headersSize": 188,
"headersSize": 186,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 204,
"statusText": "No Content"
},
"startedDateTime": "2018-08-22T07:03:38.001Z",
"time": 23,
"startedDateTime": "2019-01-29T05:33:46.820Z",
"time": 6,
"timings": {
"blocked": -1,
"connect": -1,
"dns": -1,
"receive": 0,
"send": 0,
"ssl": -1,
"wait": 23
"wait": 6
}
}
],
Expand Down
Loading

0 comments on commit f62d318

Please sign in to comment.