Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internationalized domain names are not supported on Windows #572

Closed
techtonik opened this issue Apr 1, 2017 · 5 comments
Closed

Internationalized domain names are not supported on Windows #572

techtonik opened this issue Apr 1, 2017 · 5 comments
Labels
windows Windows specific issue

Comments

@techtonik
Copy link

techtonik commented Apr 1, 2017

See https://en.wikipedia.org/wiki/Internationalized_domain_name for explanation of IDN URLs.

http --debug POST 115.бел

The command above fails, because arguments are not read with Unicode Windows API - https://stackoverflow.com/questions/846850/read-unicode-characters-from-command-line-arguments-in-python-2-x-on-windows/846931#846931

HTTPie 0.9.9
Requests 2.13.0
Pygments 2.1.3
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
c:\python27\python.exe
Windows Vista

<Environment {
    "colors": 256, 
    "config": {
        "__meta__": {
            "about": "u'HTTPie configuration file'", 
            "help": "u'https://httpie.org/docs#config'", 
            "httpie": "u'0.9.9'"
        }, 
        "default_options": "[]"
    }, 
    "config_dir": "C:\\Users\\user\\AppData\\Roaming\\\\httpie", 
    "is_windows": true, 
    "stderr": "<colorama.ansitowin32.StreamWrapper object at 0x02F65670>", 
    "stderr_isatty": false, 
    "stdin": "<open file '<stdin>', mode 'r' at 0x018BD020>", 
    "stdin_encoding": "cp437", 
    "stdin_isatty": true, 
    "stdout": "<colorama.ansitowin32.StreamWrapper object at 0x02F65530>", 
    "stdout_encoding": "cp437", 
    "stdout_isatty": true
}>

>>> requests.request(**{
    "allow_redirects": false, 
    "auth": "None", 
    "cert": "None", 
    "data": {}, 
    "files": {}, 
    "headers": {
        "User-Agent": "HTTPie/0.9.9"
    }, 
    "method": "u'post'", 
    "params": {}, 
    "proxies": {}, 
    "stream": true, 
    "timeout": 30, 
    "url": "u'http://115.???'", 
    "verify": true
})


http: error: ConnectionError: HTTPConnectionPool(host='115.', port=80): Max retries exceeded with url: /??? (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x0305BDF0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',)) while doing POST request to URL: http://115./???
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\http.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\httpie\__main__.py", line 11, in main
    sys.exit(main())
  File "c:\python27\lib\site-packages\httpie\core.py", line 227, in main
    log_error=log_error,
  File "c:\python27\lib\site-packages\httpie\core.py", line 99, in program
    final_response = get_response(args, config_dir=env.config.directory)
  File "c:\python27\lib\site-packages\httpie\client.py", line 70, in get_response
    response = requests_session.request(**kwargs)
  File "c:\python27\lib\site-packages\requests\sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\python27\lib\site-packages\requests\sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "c:\python27\lib\site-packages\requests\adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='115.', port=80): Max retries exceeded with url: /??? (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x0305BDF0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))
techtonik added a commit to techtonik/httpie that referenced this issue Apr 1, 2017
Need it for international domain names, such as 115.бел

See issue httpie#572
@techtonik
Copy link
Author

techtonik commented Apr 1, 2017

Now the problem is in argparse:

Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\lib\site-packages\httpie\__main__.py", line 54, in <module>
    main(argv)
  File "C:\Python27\lib\site-packages\httpie\__main__.py", line 47, in main
    sys.exit(main(argv))
  File "C:\Python27\lib\site-packages\httpie\core.py", line 210, in main
    parsed_args = parser.parse_args(args=args, env=env)
  File "C:\Python27\lib\site-packages\httpie\input.py", line 145, in parse_args
    self._apply_no_options(no_options)
  File "C:\Python27\lib\site-packages\httpie\input.py", line 295, in _apply_no_options
    self.error(msg % ' '.join(invalid))
  File "C:\Python27\lib\argparse.py", line 2374, in error
    self.exit(2, _('%s: error: %s\n') % (self.prog, message))
  File "C:\Python27\lib\argparse.py", line 2361, in exit
    self._print_message(message, _sys.stderr)
  File "C:\Python27\lib\site-packages\httpie\input.py", line 181, in _print_message
    message = message.encode(self.env.stdout_encoding)
  File "C:\Python27\lib\encodings\cp437.py", line 12, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
UnicodeEncodeError: 'charmap' codec can't encode characters in position 53-55: character maps to <undefined>

@techtonik
Copy link
Author

techtonik commented Apr 1, 2017

Traced the problem to httpie.input.KeyValueArgType.__call__:

__main__.py: error: argument REQUEST_ITEM: invalid <httpie.input.KeyValueArgType object
at 0x02FA4590> value: u'115.\u0431\u0435\u043b'

@techtonik
Copy link
Author

Need to find the place where argument type is determined. It should be URL and not REQUEST_ITEM (KeyValueArgType).

@techtonik
Copy link
Author

argparse is not guilty - I just passed wrong parameter to main. #573 now contain correct fix.

@techtonik techtonik changed the title Unable to fetch IDN URL on Windows Internationalized domain names are not supported on Windows Nov 24, 2017
@jkbrzt jkbrzt added the windows Windows specific issue label Jun 18, 2020
@techtonik
Copy link
Author

Python 2 is not supported by httpie and Windows is no longer supported by me. =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
windows Windows specific issue
Projects
None yet
Development

No branches or pull requests

2 participants