Commit 5bffc86c authored by Łukasz Nowak's avatar Łukasz Nowak

cli: By default do not follow redirects

parent b415bd42
......@@ -6,10 +6,11 @@ from . import recurlests
@click.option('--headers/--no-headers', help="Shows response headers", default=False, show_default=True)
@click.option('--output/--no-output', help="Shows the output", default=False, show_default=True)
@click.option('--curl', help="Path to curl binary", default='curl', show_default=True)
@click.option('--follow/--no-follow', help="Follows redirects", default=False, show_default=True)
@click.argument("url")
def runRecurl(headers, output, curl, url):
def runRecurl(headers, output, curl, follow, url):
mimikra = recurlests.Recurlests(curl)
response = mimikra.get(url)
response = mimikra.get(url, allow_redirects=follow)
print('Effective HTTP version:', response.effective_http_version)
print('Response status code:', response.status_code)
print('Response status:', response.ok and "ok" or "error")
......
......@@ -125,6 +125,8 @@ class Recurlests(object):
response.headers = CaseInsensitiveDict()
for line in response.header_text.splitlines()[1:]:
if line.strip():
if ':' not in line:
continue
header, value = line.split(':', 1)
value = value.strip()
response.headers.setdefault(header, [])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment