Variables
#
Variablesone can define variables in http file via {{var}}
. define it once and use it everywhere
#
example 1:python -m dothttp test.http
In the above httpdef
, var is set to get
. one can overwrite it via
python -m dothttp test.http --properties var=post
producing
curl -X GET 'https://httpbin.org/post?path=post'
#
example 2:curl output will be
override via properties by passing in command line
python -m dothttp --properties name=shiva lastname=prasanth
#
Environmentpassing properties from command line is not always handy. one can define
.dothttp.json
in same directory as http file
#
randomwhile integration testing, having to replace few fields are pain points. using $randomStr will generate random string of random length.
- random string ($randomStr)
- random integer ($randomInt)
- random float( $randomFloat)
- random bool ( $randomBool)
name --> shiva + "randomString of length 10 chars" height --> randomInteger of length 2
made request will like below
#
uuiduuid is completely random string with 36 char length
#
Example#
randomSlugrandomSlug
or randomLoremSlug
we’ll see random, human-readable slugs (e.g., brave-purple-penguin) in the web development world. These slugs offer the uniqueness of a number ID but can be more playful and fun.
{{$randomSlug:3}}
--> create slug with 3 (brave-purple-penguin
)
{{$randomSlug:2}}
--> create slug with 3 (brave-ranga
)
#
example#
timestampWhile testing, uniquely identifiying request is hard, one can use timestamp (epoch) in headers or queryparams to distinguish from ther requests
usage:
{{$timestamp}}
--> generates 1629338487
(current timestamp)