Package: dothttp-req
InspirationWith the rise in usage of microservices, Making http requests is essential job of most devs. For these, there are multiple options like curl, insomnia postman. My Ideal choice is to use curl but problems with it is, having no history and no easy way to save and rerun. Postman solves that problem, but once user logs in(earlier it used to be optional, now its mandatory), it stores all request metadata(body/headers/urls/credentails) to their servers although it helps solve using it across multiple devices, backup but it could be potential security loop hole if they can access it. (now a days, postman desktop is super slow also).This project aims to solve save&reuse requests, maintaining history and no sync in proprietery servers (although you can achive sync via commiting http files into git).GOALdothttp will provide simple, cleaner architecture for making http requests. It uses xtext (eclipse developed dsl) to build a custom dsl.DocumentationMore information or docs can be cound athttps://docs.dothttp.devGo through this example for better understanding. for babysteps clickhere# users.http#!/usr/bin/env /home/prasanth/cedric05/dothttp/dist/dothttp-cli# this is comment// this is also a comment/*this is multi linecomment*/# http file can have multiple requests, name tag/annotation is used to identify@name("fetch 100 users, skip first 50")# makes are get request, with url `https://req.dothttp.dev/user`GET https://req.dothttp.dev/user# below is an header example"Authorization": "Basic dXNlcm5hbWU6cGFzc3dvcmQ="# below is how you set url params '?' --> signifies url quary param? ("fetch", "100") #? ("skip", "50")? projection, name? projection, org? projection, location# makes are post request, with url `https://req.dothttp.dev/user`POST https://req.dothttp.dev/userbasicauth('username', 'password')/*below defines payload for the post request.json --> signifies payload is json data*/json({"name": "{{name=adam}}", # name is templated, if spcified via env or property, it will be replaced"org": "dothttp","location": "Hyderabad",# "interests": ["exploring", "listening to music"],})# makes put request, with url `https://req.dothttp.dev/user/1`PUT https://req.dothttp.dev/post# define headers in .dothttp.json with envbasicauth("{{username}}, "{{password}}")# posts with urlencodeddata({"name": "Adam A","org": "dothttp","location": "Hyderabad","interests": ["exploring", "listening to music"],})// or use below one// data('name=Adam+A&org=dothttp&location=Hyderabad&interests=%5B%27exploring%27%2C+%27listening+to+music%27%5D')KICKSTARTFrom pypipipinstalldothttp-req==0.0.10From sourcegitclonegit@github.com:cedric05/dothttp.gitcddothttp

python3-mpipinstallpipenv
pipenvinstallpython3.9python3-mdothttpexamples/dothttpazure.httpdockerdockerbuild-tdothttp.
dockerrun-it--rmdothttpwhalebrewdockerrun-it--rmdothttpFeatureseasy and cleaner http syntaxvariable substitution with property filegenerates curl from http for easy sharingdockerbuild-tdothttp.
whalebrewinstalldothttp
dothttpexamples/dothttpazure.httpFirst DotHttpRequest and moreGET "http://localhost:8000/get"dothttp get.httporpython -m dothttp get.httpRundothttp simple.httpprints{"args":{},"headers":{"Accept-Encoding":"identity","Host":"httpbin.org","User-Agent":"python-urllib3/1.26.3","X-Amzn-Trace-Id":"Root=1-6022266a-20fb552e530ba3d90c75be6d"},"origin":"117.216.243.24","url":"http://localhost:8000/get"}POST requestPOST "http://localhost:8000/post"{"args":{},"data":"","files":{},"form":{},"headers":{"Accept-Encoding":"identity","Content-Length":"0","Host":"httpbin.org","User-Agent":"python-urllib3/1.26.3","X-Amzn-Trace-Id":"Root=1-602228fa-3c3ed5213b6d8c2d2a223148"},"json":null,"origin":"117.216.243.24","url":"http://localhost:8000/post"}similarly, other methodsGET, POST, OPTIONS, DELETE, CONNECT, PUT, HEAD, TRACEsupport is available.Queryquery params can be added to request by specifyingquery ( "key", "value")?  "key", "value"? "key": "value"? "key"= "value"all four are accepted. going withquery("hi", "hi2)is more readable.?"key"= "value"is more concisePayloaduser can specify payload by mentioning below four forms (for various scenarios).data("ram")user can also mention itscontent-typewithdata("ram", "text/plain")data({"key": "value"})for form input.json({"key": "value"})for json payload.fileinput("path/to/file", "type")uploads file as payload (type is optional).files(("photo", "path/to/file/photo.jpg", "image/jpeg"), ("photo details", '{"name":"prasanth"}', "application/json")    )for multipart uploaddothttpwill figure out content type by going through file/data, when type is not mentioned.Commentsdothttpwill use#for commenting entire line.//line comment. follows java, javascript#line comment. follows python's comment style/* */multi line comment. follows java/javascript styleTemplatingPOST 'http://localhost:8000/post'
? ("{{key}}", "{{value}}")
data('{"{{key}}" :"{{value}}"}', 'application/json')specify variable values through property file (sample.json).user can define environments and can activate multiple environments at a timedothttpby default will read variables from"*"sectionfor exampledothttp --property-file path/to/file.json --env ram chandrawill activate*section properties,ramsection properties andchandrasection propertiesdothttp --env ram chandrawill activate*section properties,ramsection properties andchandrasection properties
from.dothttp.jsonin httpfile name spacethrough command linedothttp --property key=ram value=rangawill replace{{ram}}torangafrom the filethrough file itself. (will be helpful for default properties)POST 'https://{{host=httpbin.org}}/post'HeadersUser can define headers in below three formatsheader('content-type', 'application/json')readable'content-type': 'application/json'conciseproperty fileheaderssection from property-file can also be used. in most scenarios, headers section will be
common for a host. having them in property file would ease them.AuthenticationBasicAuthbasicauth('username','password')'--> will compute add respective headers.DigestAuthdigestauth('username','password')'--> will compute add respective headers.NtlmAuthntlmauth('username','password')'--> will compute add respective headers.Property file{"*":{"host":"httpbin.org"},"headers":{"content-type":"plain/text"},"preprod":{"host":"preprod.httpbin.org"}}Special sections in property file*section in property file will be activated once user specifies property file if user didn't specifiy file
and.dothttp.jsonexists, it will be activatedheadersonce a property file is activated. headers from property file will be added to request by default without
user having to specify in.httpfileFormatter (experimental phase)dothttpcan format a http file using below commanddothttp -fmt examples/dothttpazure.http --experimentalordothttp --format examples/dothttpazure.http --experimentalto print to command linedothttp --format examples/dothttpazure.http --experimental --stdoutEditor supportsyntax highlighting for visual studio code is supported
viadothttp-codeCommand line optionsusage: dothttp [-h] [--curl] [--property-file PROPERTY_FILE] [--no-cookie] [--env ENV [ENV ...]] [--debug] [--info] [--format] [--stdout]
               [--property PROPERTY [PROPERTY ...]]
               file

http requests for humans

optional arguments:
  -h, --help            show this help message and exit

general:
  --curl                generates curl script
  --no-cookie, -nc      cookie storage is disabled
  --debug, -d           debug will enable logs and exceptions
  --info, -i            more information
  file                  http file

property:
  --property-file PROPERTY_FILE, -p PROPERTY_FILE
                        property file
  --env ENV [ENV ...], -e ENV [ENV ...]
                        environment to select in property file. properties will be enabled on FIFO
  --property PROPERTY [PROPERTY ...]
                        list of property's

format:
  --format, -fmt        formatter
  --stdout              print to commandlinecheckoutexamplesVscode alternativesrest-clientwritten in typescripthttpYacwritten in typescriptThunder Clientclosed sourceNon Vscode alternativeshttp-clientclosed sourcedothttpwritten in python