Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
pdrb committed Aug 15, 2023
1 parent b78a0d5 commit cea96b7
Showing 1 changed file with 26 additions and 75 deletions.
101 changes: 26 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,63 +14,10 @@ Or download the appropriate pre-built binary from [Releases](https://github.com/
## Usage

```text
Usage: gurl <command>
Usage: gurl <url>
A simple http client cli written in Go.
Flags:
-h, --help Show context-sensitive help.
-u, --auth=auth Basic HTTP authentication in the format
username:password.
-b, --bearer-token=token Set bearer auth token.
--ca-cert=file CA certificate file.
--client-cert=cert-file,key-file,...
Client cert and key files separated by comma:
"cert.pem,key.pem".
--disable-redirect Disable redirects.
--force-http-1 Force HTTP/1.1 to be used.
-H, --headers=h1=v1;h2=v2 HTTP headers in the format:
"header1=value1;header2=value2".
--impersonate="none" Fully impersonate chrome, firefox or safari
browser (this will automatically set headers,
headers order and tls fingerprint).
-k, --insecure Allow insecure SSL connections.
-o, --output-file=file Save response to file.
--proxy=proxy Proxy to use, e.g.:
"http://user:pass@myproxy:8080".
--raw-response Print raw response string (disable json
prettify).
-r, --retries=0 Number of retries in case of errors and http
status code >= 500.
-t, --timeout=10000 Timeout in milliseconds.
--tls-finger="go" TLS Fingerprint: chrome, firefox, edge, safari,
ios, android, random or go.
--trace Show tracing/performance information.
-A, --user-agent=agent Set User-Agent http header.
-v, --verbose Enable verbose/debug mode.
Commands:
get GET HTTP method.
head HEAD HTTP method.
post POST HTTP method.
put PUT HTTP method.
patch PATCH HTTP method.
delete DELETE HTTP method.
options OPTIONS HTTP method.
version Show version and exit.
Run "gurl <command> --help" for more information on a command.
```

Each command has it's own help, for example:

```text
$ gurl post --help
Usage: gurl post <url>
POST HTTP method.
Arguments:
<url> Url to access.
Expand All @@ -83,6 +30,11 @@ Flags:
--client-cert=cert-file,key-file,...
Client cert and key files separated by comma:
"cert.pem,key.pem".
-c, --content-type=content Content-Type http header, default is
application/json for post, put and patch
methods.
-d, --data=payload Data payload (request body).
-f, --data-file=file Read data payload from file.
--disable-redirect Disable redirects.
--force-http-1 Force HTTP/1.1 to be used.
-H, --headers=h1=v1;h2=v2 HTTP headers in the format:
Expand All @@ -91,6 +43,8 @@ Flags:
browser (this will automatically set headers,
headers order and tls fingerprint).
-k, --insecure Allow insecure SSL connections.
-X, --method="get" Http method: get, head, post, put, patch,
delete or options.
-o, --output-file=file Save response to file.
--proxy=proxy Proxy to use, e.g.:
"http://user:pass@myproxy:8080".
Expand All @@ -104,36 +58,33 @@ Flags:
--trace Show tracing/performance information.
-A, --user-agent=agent Set User-Agent http header.
-v, --verbose Enable verbose/debug mode.
-d, --data=payload Data payload (request body).
-f, --data-file=file Read data payload from file.
-c, --content-type=content Content-Type http header, default is
application/json.
-V, --version Show version and exit.
```

## Example

```text
$ gurl post 'https://httpbin.org/anything?var1=value1&var2=value2' \
-u user:pass -H 'header1=value1;header2=value2' \
$ gurl -X post 'https://httpbin.org/anything?var1=value1&var2=value2' \
-u user:pass \
-H 'header1=value1;header2=value2' \
-d '{"user": "name"}' \
-v --trace
2023/08/10 01:10:18.662247 DEBUG [req] HTTP/2 POST https://httpbin.org/anything?var1=value1&var2=value2
2023/08/14 22:06:14.375996 DEBUG [req] HTTP/2 POST https://httpbin.org/anything?var1=value1&var2=value2
:authority: httpbin.org
:method: POST
:path: /anything?var1=value1&var2=value2
:scheme: https
header2: value2
user-agent: gurl 1.2.0
content-type: application/json; charset=utf-8
authorization: Basic dXNlcjpwYXNz
header1: value1
header2: value2
user-agent: gurl 1.3.0
content-length: 16
accept-encoding: gzip
:status: 200
date: Thu, 10 Aug 2023 04:10:20 GMT
date: Tue, 15 Aug 2023 01:06:15 GMT
content-type: application/json
content-length: 644
server: gunicorn/19.9.0
Expand All @@ -156,8 +107,8 @@ access-control-allow-credentials: true
"Header1": "value1",
"Header2": "value2",
"Host": "httpbin.org",
"User-Agent": "gurl 1.2.0",
"X-Amzn-Trace-Id": "Root=1-64d4632b-6cbed42b1c30160e29d66ed0"
"User-Agent": "gurl 1.3.0",
"X-Amzn-Trace-Id": "Root=1-64dacf87-53be09483437853617291edd"
},
"json": {
"user": "name"
Expand All @@ -168,14 +119,14 @@ access-control-allow-credentials: true
}
------- TRACE INFO -------
TotalTime : 1.4490617s
DNSLookupTime : 3.7486ms
TCPConnectTime : 149.5495ms
TLSHandshakeTime : 304.5126ms
FirstResponseTime : 985.7845ms
ResponseTime : 544.1µs
TotalTime : 695.0164ms
DNSLookupTime : 19.5851ms
TCPConnectTime : 158.1832ms
TLSHandshakeTime : 327.1256ms
FirstResponseTime : 185.8961ms
ResponseTime : 535.4µs
IsConnReused: : false
RemoteAddr : 54.236.190.246:443
RemoteAddr : 3.225.120.215:443
the request total time is 1.4490617s, and costs 985.7845ms from connection ready to server respond first byte
the request total time is 695.0164ms, and costs 327.1256ms on tls handshake
```

0 comments on commit cea96b7

Please sign in to comment.