Set the add_content_type when adding non-binary data with the "-d" and
"--data" options so that a "Content-Type:
application/x-www-form-urlencoded" header will get added to the
request.
Chrome's 'Copy as cURL' option generates "-X PATCH -H 'Content-Type:
application/json' --data-binary '<json...>'" options to construct a
PATCH request that contains a JSON body. This commit allows wuzz to
send such a request by making the following changes:
Modify App.ParseArgs to support the "--data-binary" option. When this
option is specified, do not pass the body through url.QueryUnescape
and do not add automatically a "Content-Type:
application/x-www-form-urlencoded" header to the request.
Modify App.ParseArgs to remember if the request method has been
explicitly set via the "-X" or "--request" options and in such
situations to not automatically set the request method to POST when
request data is present.
Modify App.SubmitRequest to include the request body if the method is
PATCH.
Modify App.SubmitRequest to not replace newlines (\n) with
ampersands (&) in the request body unless a "Content-Type:
application/x-www-form-urlencoded" header exists. This required
moving the creation of the headers to be before the creation of the
body and the actual request.
The new configuration system, using TOML, loads into `app.config`
using a TOML config file. This can be specified on the command-line
with the `-c` option, or it can be at one of the following default
locations:
- Linux: $XDG_CONFIG_HOME/wuzz/config.toml (by default this is ~/.config/wuzz/config.toml)
- Other OSs: ~/.wuzz/config.toml
Currently the following keys can be set, along with their default
values:
```toml
[general]
timeout = "1m" # string parsed into time.Duration
formatJSON = true # toggles JSON formatting
preserveScrollPosition = true # currently unused
defaultURLScheme = "https" # when a URL is not provided, this is the scheme used by default
```
In addition, a [keys] section can also be set and will be successfully
parsed, but it is currently non-functional.
This PR uses the jsoncolor package to colorize JSON bodies. It
changes the imports to use my forked version of
github.com/jroimartin/gocui which includes a small patch to support
zero-parameter CSI escape sequences. I have submitted a PR upstream:
https://github.com/jroimartin/gocui/pull/98
Once that PR is merged the import can be switched back to
github.com/jroimartin/gocui if desired.