Skip to content

Commit 1789223

Browse files
authored
feat: add --location option to follow HTTP redirects
1 parent 11346c3 commit 1789223

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

http-cli

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Options:
4242
-c, --cookie-jar file Write all cookies to a file
4343
-d, --data data Request body (string or @file)
4444
-D, --dump-header file Dump headers info (file=- or emtpy shows full headers)
45+
-L, --location Follow HTTP redirects
4546
-Z, --status-codes Status codes (proxy + server, HTTP only)
4647
-x, --proxy proxy Proxy URL
4748
-t, --timeout timeout Request timeout (default: 30)
@@ -187,6 +188,12 @@ function set_dump_header() {
187188
log "set dump header => $file"
188189
}
189190

191+
# location
192+
function set_location() {
193+
add_engine_flag --location
194+
log "set location"
195+
}
196+
190197
# method
191198
function set_method() {
192199
HTTP_METHOD=$(echo "$1" | tr "[:lower:]" "[:upper:]")
@@ -347,6 +354,10 @@ function parse_args() {
347354
usage
348355
exit 0
349356
;;
357+
-L|--location)
358+
set_location
359+
shift
360+
;;
350361
-m|--method)
351362
ensure_arg "$1" "$2"
352363
set_method "$2"

0 commit comments

Comments
 (0)