5

According to the official documentation httpie tool also works on Windows 10, however when I run the command in terminal it simply hangs and nothing happens:

$ http :8000/

Is there an explanation what is going on and preferably a workaround?

Evgeny Bobkin
  • 4,092
  • 2
  • 17
  • 21

1 Answers1

12

I was able to get a hint by appending the --debug parameter:

$ http localhost:8000 --debug
HTTPie 0.9.9
Requests 2.12.4
Pygments 2.1.3
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)]
c:\users\...\venv\scripts\python.exe
Windows 10

<Environment {
  "colors": 256,
  "config": {
    "__meta__": {
        "about": "HTTPie configuration file",
        "help": "https://httpie.org/docs#config",
        "httpie": "0.9.9"
    },
    "default_options": "[]"
  },
  "config_dir": "C:\\Users\\...\\AppData\\Roaming\\\\httpie",
  "is_windows": true,
  "stderr": "<colorama.ansitowin32.StreamWrapper object at 0x0000000003CDAB00>",
  "stderr_isatty": false,
  "stdin": "<_io.TextIOWrapper name='<stdin>' mode='r' encoding='cp1252'>",
  "stdin_encoding": "cp1252",
  "stdin_isatty": false,
  "stdout": "<colorama.ansitowin32.StreamWrapper object at 0x0000000003CDA9B0>",
  "stdout_encoding": "cp1252",
  "stdout_isatty": false
}>

The crucial point is that the isatty related option is set to false.

I was able to resole it and getting http working as expected by prepending the winpty command:

$ winpty http :8000
HTTP/1.0 200 OK
Content-Type: application/json
Date: Fri, 16 Dec 2016 19:56:58 GMT
Server: WSGIServer/0.2 CPython/3.4.4
X-Frame-Options: SAMEORIGIN

{
    "status": "ok"
}

Solution:

By adding this alias line

alias http='winpty http' 

to the ~/.profile file, one can use the initial command http as expected with git bash.

Evgeny Bobkin
  • 4,092
  • 2
  • 17
  • 21
  • 1
    This is [a bug in Git for Windows](https://github.com/git-for-windows/git/issues/778). To make the workaround easier, you could add `"--ignore-stdin"` to the `default_options` list in your `config.json` (in `C:\\Users\\...\\AppData\\Roaming\\\\httpie`). Then HTTPie wouldn't attempt to read `stdin` unless that option is reverted with `--no-ignore-stdin`. – Jakub Roztocil Dec 16 '16 at 22:47
  • 1
    @jkbrzt Thank you for the answer, much appreciated. I added an alias by adding this line `alias http='winpty http'` to the `~/.profile` file. Now, I can use the initial command as expected. – Evgeny Bobkin Dec 18 '16 at 20:39