forked from reqable/python-scripting-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddons.py
36 lines (25 loc) · 756 Bytes
/
addons.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# API Docs: https://reqable.com/docs/capture/addons
from reqable import *
def onRequest(context, request):
# Print url to console
# print('request url ' + context.url)
# Update or add a query parameter
# request.queries['foo'] = 'bar'
# Update or add a http header
# request.headers['foo'] = 'bar'
# Replace http body with a text
# request.body = 'Hello World'
# Map with a local file
# request.body.file('~/Desktop/body.json')
# Convert to dict if the body is a JSON
# request.body.jsonify()
# Update the JSON content
# request.body['foo'] = 'bar'
# Done
return request
def onResponse(context, response):
# Update status code
# response.code = 404
# APIs are same as `onRequest`
# Done
return response