Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions httpie/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ def collect_messages(
verify=bool(send_kwargs_mergeable_from_env['verify'])
)

# Warn about insecure HTTP usage
if not args.offline and args.url.lower().startswith('http://'):
from urllib.parse import urlparse
from .context import LogLevel

parsed_url = urlparse(args.url)
warning_msg = (
f"The request is using HTTP instead of HTTPS. "
f"Data will be sent in plain text and is vulnerable to eavesdropping. "
f"Consider using HTTPS for secure communication."
)

# Add extra warning if authentication is being used
if args.auth or (httpie_session and httpie_session.auth):
warning_msg += (
f"\nWARNING: Authentication credentials will be sent in plain text "
f"and can be intercepted!"
)

env.log_error(warning_msg, level=LogLevel.WARNING)

if httpie_session:
httpie_session.update_headers(request_kwargs['headers'])
requests_session.cookies = httpie_session.cookies
Expand Down