You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d9e5677
Browse filesBrowse the repository at this point in the historyBrowse files
SGrondin
committed
Merge branch 'master' of github.com:ahmadnassri/httpsnippet
|`source.fullUrl`| the full & final url, including all query string values |
158
+
|`source.uriObj`| the url parsed with `url.parse()`. compatible with `url.format`|
159
+
|`source.queryObj`| a key => value pair, "normalized" version of `source.queryString`, adds additional query string values from the `source.url`|
160
+
|`source.headersObj`| a key => value pair, "normalized" version of `source.headers`, header names are lowercased |
161
+
|`source.allHeaders`| same as `source.headersObj` but with `cookies` header and populated from `source.cookies` array |
162
+
|`source.postData.jsonObj`| the parsed value of `source.postData.text`, only for `source.postData.mimeType` = `application/json`*(or equivalent mimeTypes)*|
163
+
|`source.postData.paramsObj`| a key => value pair, "normalized" version of `source.postData.params`, only for `source.postData.mimeType` = `application/x-www-form-urlencoded`|
// this value will be always overwritten in this scenario
306
+
text:'baz=abc&foo=bar&foo=baz'
307
+
308
+
// see below
309
+
jsonObj:false
310
+
}
311
+
```
312
+
313
+
###### application/json
314
+
315
+
- will match when `postData.mimeType` is one of: `application/json`, `text/json`, `text/x-json`, `application/x-json`
316
+
- In case of failure to parse `postData.text` as a JSON object, `postData.mimeType` is set to `text/plain`, `postData.jsonObj` remains as `false`. this is done so that the implementing target, would still attempt to post the raw body as is.
317
+
- This also emphasizes not to rely on `postData.mimeType` for the `Content-Type` header!
318
+
319
+
```js
320
+
postData: {
321
+
// added to pass har-validator
322
+
size:0,
323
+
324
+
// original value
325
+
mimeType:'application/json',
326
+
327
+
// ignored
328
+
params: [],
329
+
330
+
// default value
331
+
paramsObj:false
332
+
333
+
// the raw body in plain text
334
+
text:'"{\"foo\": \"bar\"}"'
335
+
336
+
// the parsed value of postData.text
337
+
jsonObj: {
338
+
foo:'bar'
339
+
}
340
+
}
341
+
```
342
+
343
+
###### multipart/form-data
344
+
345
+
- will match when `postData.mimeType` is one of: `multipart/mixed``multipart/related`, `multipart/form-data`, `multipart/alternative`
346
+
- will force `postData.mimeType` to `multipart/form-data`
347
+
- will create/overwrite the `Content-Type` header if it does not exist, with the appropriate boundary flag.
348
+
- when no `params[].value` is present, will default to empty content
349
+
350
+
```js
351
+
postData: {
352
+
// added to pass har-validator
353
+
size:0,
354
+
355
+
// original value
356
+
mimeType:'multipart/form-data',
357
+
358
+
// parsed into text values
359
+
params: [
360
+
{
361
+
name:'foo',
362
+
value:'bar'
363
+
}
364
+
]
365
+
366
+
// ignored
367
+
paramsObj:false
368
+
369
+
// the raw body in plain text
370
+
// generated based on appropriately parsing the `params` into a multi-boundary content string
371
+
// this value will be always overwritten in this scenario
0 commit comments