GithubHelp home page GithubHelp logo

httpie / http-prompt Goto Github PK

View Code? Open in Web Editor NEW
8.9K 170.0 328.0 736 KB

An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie

Home Page: https://http-prompt.com

License: MIT License

Python 99.84% Makefile 0.16%
http-client cli rest-api developer-tools autocomplete syntax-highlighting http development web-development json

http-prompt's Introduction

http-prompt's People

Contributors

ace-wu avatar alansill avatar bobotig avatar dargad avatar delirious-lettuce avatar dfrommi avatar elenalape avatar eliangcs avatar eungjun-yi avatar jkbrzt avatar jonathanslenders avatar karlcow avatar kiranbaktha avatar lalmeras avatar lonetwin avatar mikeecb avatar nheisterkamp avatar poetro avatar rmax avatar sirbranedamuj avatar tangestani avatar tardypad avatar thegrammarnazi avatar timka avatar tsabirgaliev avatar vtrbtf avatar yegorov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

http-prompt's Issues

Allow launching with options & settings

Awesome project! 👍

I have an endpoint that I hit with an invalid cert & various headers:

http --verify=no POST https://localhost...  'Authorization:...'

I would love to make a script to launch http-prompt with that already prepared.
My current understanding is that I can set up the URL, but not the --verify or Authorization parts.

Support "ls" command and endpoint definitions

I've been using this program for a few days now and overall I love it. I'm using it to test endpoints while developing my API.

One issue I have however is that whenever I type cd, my muscle memory kicks in and I immediately follow with an ls out of habit. It's always a little disappointing when this doesn't work :( I was thinking of ways to solve this, and it would be great if I could pass in my endpoint definition file ala

$ http-prompt --specification=my_api_spec.json

This would enable http-prompt to do a bunch of smart things like suggest endpoints when I type ls or autocomplete parameter names. Could also add a help command to view the documentation for any given endpoint. There are a couple of widely used spec formats, with Swagger probably being the most popular

http://nordicapis.com/top-specification-formats-for-rest-apis/

DistributionNotFound: six>=1.10.0

Traceback (most recent call last):
File "/usr/bin/http-prompt", line 5, in
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2603, in
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 666, in require
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 565, in resolve
pkg_resources.DistributionNotFound: six>=1.10.0

pexpect: test failed on pypy3

Not sure why. test_interaction() in tests/test_interaction.py is failing on pypy3 on Travis CI:

=================================== FAILURES ===================================
_______________________________ test_interaction _______________________________
    @pytest.mark.skipif(sys.platform == 'win32',
                        reason="pexpect doesn't work well on Windows")
    @pytest.mark.slow
    def test_interaction():
        bin_path = get_http_prompt_path()
        child = pexpect.spawn(bin_path)

        # TODO: Test more interaction

        child.sendline('exit')
>       child.expect_exact('Goodbye!', timeout=20)
tests/test_interaction.py:19: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../virtualenv/pypy3-2.4.0/site-packages/pexpect/spawnbase.py:390: in expect_exact
    return exp.expect_loop(timeout)
../../../virtualenv/pypy3-2.4.0/site-packages/pexpect/expect.py:107: in expect_loop
    return self.timeout(e)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <pexpect.expect.Expecter object at 0x0000000004e456e0>
err = TIMEOUT('Timeout exceeded.',)
    def timeout(self, err=None):
        spawn = self.spawn
        from . import TIMEOUT

        spawn.before = spawn.buffer
        spawn.after = TIMEOUT
        index = self.searcher.timeout_index
        if index >= 0:
            spawn.match = TIMEOUT
            spawn.match_index = index
            return index
        else:
            spawn.match = None
            spawn.match_index = None
            msg = str(spawn)
            msg += '\nsearcher: %s' % self.searcher
            if err is not None:
                msg = str(err) + '\n' + msg
>           raise TIMEOUT(msg)
E           pexpect.exceptions.TIMEOUT: Timeout exceeded.
E           <pexpect.pty_spawn.spawn object at 0x0000000004e45248>
E           command: /home/travis/virtualenv/pypy3-2.4.0/bin/http-prompt
E           args: ['/home/travis/virtualenv/pypy3-2.4.0/bin/http-prompt']
E           buffer (last 100 chars): b'exit\r\nVersion: 0.2.0\r\n'
E           before (last 100 chars): b'exit\r\nVersion: 0.2.0\r\n'
E           after: <class 'pexpect.exceptions.TIMEOUT'>
E           match: None
E           match_index: None
E           exitstatus: None
E           flag_eof: False
E           pid: 2532
E           child_fd: 11
E           closed: False
E           timeout: 30
E           delimiter: <class 'pexpect.exceptions.EOF'>
E           logfile: None
E           logfile_read: None
E           logfile_send: None
E           maxread: 2000
E           ignorecase: False
E           searchwindowsize: None
E           delaybeforesend: 0.05
E           delayafterclose: 0.1
E           delayafterterminate: 0.1
E           searcher: searcher_string:
E               0: "b'Goodbye!'"
../../../virtualenv/pypy3-2.4.0/site-packages/pexpect/expect.py:70: TIMEOUT

See full log at https://travis-ci.org/eliangcs/http-prompt/jobs/133855030.

Question: Storing cookies

Hi, nice app!
Can http-prompt store cookies automatically from a response like this?

Set-Cookie: author=f0a117c7-75a4-4abe-8617-1d3d06c4d2a7; path=/; httponly
Set-Cookie: author.sig=y4Kfr_MNE7RJmeL1x6vLhixHUAo; path=/; httponly

What I do now is copy/pasting (a bit painful):

Cookie:author=f0a117c7-75a4-4abe-8617-1d3d06c4d2a7;author.sig=y4Kfr_MNE7RJmeL1x6vLhixHUAo;

Don't trim trailing slashes

Context trims trailing slashes; I'm not sure what the reasoning behind this is, but it leads to being unable to use http-prompt to browse certain sites. Maybe at least allow an option to not trim them?

Here's a (rather timely) example of http-prompt not being able to interact with a site due to this:

https://events.google.com> get /io2016/ --verbose
GET /io2016 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: events.google.com
User-Agent: HTTPie/0.9.3



HTTP/1.1 301 Moved Permanently
Alt-Svc: quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"
Alternate-Protocol: 443:quic
Content-Length: 43
Content-Type: text/html; charset=utf-8
Date: Thu, 19 May 2016 18:34:44 GMT
Location: /io2016/
Server: Google Frontend

<a href="/io2016/">Moved Permanently</a>.



GET /io2016 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: events.google.com
User-Agent: HTTPie/0.9.3



HTTP/1.1 301 Moved Permanently
Alt-Svc: quic=":443"; ma=2592000; v="34,33,32,31,30,29,28,27,26,25"
Alternate-Protocol: 443:quic
Content-Length: 43
Content-Type: text/html; charset=utf-8
Date: Thu, 19 May 2016 18:35:24 GMT
Location: /io2016/
Server: Google Frontend

<a href="/io2016/">Moved Permanently</a>.

Define a python/REPL syntax

Another thing I would find SUPER useful would be the ability to use http-prompt as a normal Python REPL.

I'm imagining that this would either be with back ticks, a python() function, or a python statement.

For instance, if I could do something like:

https://api.amazon.com> `import settings.API_KEY as api_secret_key`
https://api.amazon.com> api_key=`api_secret_key`
https://api.amazon.com> nonce=`import random; random.randint(0, 99)`
https://api.amazon.com> post

This would be so, so amazing.

Proposal to export the builded request

After finally excecuting a request and checking is good, it would be nice to export that request in different formats, like httpie, curl or raw, in order to share it with others or for documentation.

Use proper terminology

Correct the terminology used in code and documentation so that it is consistent with HTTPie and web standards. Examples:

  • body parameter -> data field
  • operator -> separator

Support shell commands

Allow users to do embed shell commands like this:

> "Authorization:Basic `cat ~/.apiauths | grep JIRA`"

Releated: #13

HTTP HEAD is missing

HTTP HEAD is missing in the possible commands.
https://github.com/eliangcs/http-prompt/blob/02986bb4cf3d29553c43ba6a5369e9f60c86e109/http_prompt/lexer.py#L37

→ http-prompt http://w3.org/
Version: 0.1.1
http://w3.org> head
Syntax error near ""
http://w3.org> 

while

→ http HEAD http://www.w3.org/
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=600
Content-Length: 48691
Content-Location: Home.html
Content-Type: text/html; charset=utf-8
Date: Thu, 19 May 2016 22:59:18 GMT
ETag: "be33-53339ddfc3880;89-3f26bd17a2f00"
Expires: Thu, 19 May 2016 23:09:18 GMT
Last-Modified: Thu, 19 May 2016 22:55:14 GMT
P3P: policyref="http://www.w3.org/2014/08/p3p.xml"
TCN: choice
Vary: negotiate,accept,upgrade-insecure-requests

HTTPie := separator does not work

> httpie post / definition:='{"id": 819, "name": "ML"}'
http POST http://localhost/ definition:= '{"id": 819, "name": "ML"}'
post / definition:='{"id": 819, "name": "ML"}'
usage: http-prompt [--json] [--form] [--pretty {all,colors,format,none}]
                   [--style STYLE] [--print WHAT] [--headers] [--body]
                   [--verbose] [--all] [--history-print WHAT] [--stream]
                   [--output FILE] [--download] [--continue]
                   [--session SESSION_NAME_OR_PATH | --session-read-only SESSION_NAME_OR_PATH]
                   [--auth USER[:PASS]] [--auth-type {basic,digest}]
                   [--proxy PROTOCOL:PROXY_URL] [--follow]
                   [--max-redirects MAX_REDIRECTS] [--timeout SECONDS]
                   [--check-status] [--verify VERIFY]
                   [--ssl {ssl2.3,ssl3,tls1,tls1.1,tls1.2}] [--cert CERT]
                   [--cert-key CERT_KEY] [--ignore-stdin] [--help] [--version]
                   [--traceback] [--debug]
                   [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]
http-prompt: error: "definition:=": Expecting value: line 1 column 1 (char 0)

The extra space between definition:= and raw JSON value causes HTTPie argument parsing to fail.

Output colors on FreeBSD

Hi.

As talked through email, on execution.py if I remove "stdout=output", the output colors works out.
#env = Environment(stdout=output)
env = Environment()

Otherwise, is all printed without colors.

Using shells csh and zsh.

screen shot 2016-05-23 at 16 44 50

screen shot 2016-05-23 at 16 45 09

Thanks and congrats for this tool.

malformed URL not handled (unexpected ":")

When one replaces in an URL a dot by a colon, an exception is not caught:

C:\>http-prompt https://google:com
Version: 0.5.0
Traceback (most recent call last):
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\yop\AppData\Local\Programs\Python\Python35-32\Scripts\http-prompt.exe\__main__.py", line 9, in <module>
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 696, in main
    rv = self.invoke(ctx)
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\site-packages\click\core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\site-packages\http_prompt\cli.py", line 94, in cli
    load_context(context)
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\site-packages\http_prompt\contextio.py", line 30, in load_context
    filename = url_to_context_filename(context.url)
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\site-packages\http_prompt\contextio.py", line 21, in url_to_context_filename
    port = r.port
  File "c:\users\yop\appdata\local\programs\python\python35-32\lib\urllib\parse.py", line 158, in port
    port = int(port, 10)
ValueError: invalid literal for int() with base 10: 'com'

Add ability to add headers from command-line

I saw that http-prompt accepts options beginning with dashes from the command line. However I didn't see a way to pass headers from the outside. Setups requiring many headers to be added are tedious since they require re-adding the headers on each new session.

It would be awesome to have a flag for adding headers from the command line.

Thanks!

Specifying options inline does not work properly

When trying to specify a param inline, the input does not accept a space character after the URL. Note below the lack of space between /api/something and page==2. The cursor also resets to position 0 in this situation.

output

The command actually works, but the command line processing is not handled properly.

Encoding limited for Python2. Works well in Python3

Only in Python2. In Python3 is working great.

Writing any non ascii character (I was writing Jesús, the ú raised the error) in the prompt gives me this error:

Exception in thread Thread-13:
Traceback (most recent call last):                                     
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_innr
    self.run()                                                         
  File "/usr/lib/python2.7/threading.py", line 754, in run             
    self.__target(*self.__args, **self.__kwargs)                       
  File "/usr/local/lib/python2.7/dist-packages/prompt_toolkit/interfacn
    completions = list(buffer.completer.get_completions(document, comp)
  File "/usr/local/lib/python2.7/dist-packages/http_prompt/completer.ps
    for comp in match_completions(cur_word, word_dict):
  File "/usr/local/lib/python2.7/dist-packages/http_prompt/completer.ps
    suggestions = fuzzyfinder(cur_word, words)
  File "/usr/local/lib/python2.7/dist-packages/http_prompt/completer.pr
    text = str(text) if not isinstance(text, str) else text
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfa' in po)

[INVALID] Windows binary

Dear Chang-Hung,
Could you be so kind to generate .exe for the rest of us who are merely users w/o compiler?

Exception http: error: AttributeError: '_io.BytesIO' object has no attribute 'encoding'

I'm having exception, when I send get request.
Example:

http-prompt google.com
Version: 0.2.0
http://google.com> get

http: error: AttributeError: '_io.BytesIO' object has no attribute 'encoding'

http://google.com>

Version Python:

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

Feature proposal: saving current request setup under named alias

This is great package, thanks for sharing your work!

As I've been using it couple of days I noticed that it's quite inconvenient, having to repeatedly change request settings every time I want to send different request.
The option of saving current state of request would solve the problem.

Given this output of httpie post:

http://127.0.0.1:3000/api/oauth/token> http --form --style native POST http://127.0.0.1:3000/api/oauth/token user_id==value client_id=value client_secret=value grant_type=password password=test  username=testuser1 Content-Type:application/x-www-form-urlencoded

We could use eg.: http://127.0.0.1:3000/api/oauth/token> alias getToken

which would save the request under getToken keyword. Later, we could call getToken request and optionally overwrite any req options like so:

http://127.0.0.1:3000/api/oauth/token> getToken username=testuser2 password=test2

Any way to persist options?

I decided to test this while implementing some changes to an endpoint. I need to make the same request back to back. Hitting "up" and using the same line to set headers is not horrible, but it would be nice and interesting (and makes sense with the tool, IMO) if I could persist these settings until a clear them. Even if this an opt-into kind of behavior I think it would be nice and would definitely encourage me to use this over something like Postman where I can enter everything once and just keep hitting the "GET" button.

Custom prompt text

Just like how Unix allows users to change their prompt text using PS1 environment variable, http-prompt should support custom prompt text by introducing a prompt option in config.py, so users can add something like the following in their config:

prompt = '{path[-2:]}'

In Python, path[-2:] means getting the last two elements of variable path.

Suppose the current URL is http://example.com/api/v1/user, the above prompt setting will result in:

v1/user>

instead of showing the full URL like the current implementation.

Add mouse support

Here's an example where this would be useful. I want to re-run the previous command, but I need to swap out a long uid that was passed in the request body. Currently I need to press up, and then use the left arrow key to scroll back to that point in the request, hold the delete key until the uid is deleted, and then right-click to paste. Ideally I would be able to just highlight that uid with the mouse and right-click to paste over it.

prompt_toolkit supports it out of the box so it should be an easy addition.
http://python-prompt-toolkit.readthedocs.io/en/stable/pages/building_prompts.html#mouse-support

Autocomplete for multiple header values

Autocomplete should work for multiple header values separated by semicolons or commas depending on the header being used. Example:

Content-Type:text/html;charset=utf-8
Accept:"text/plain, text/html"
'Cookie:a=1; b=2'

Installation fails on system-wide install on os.x

From the debug log:

Cleaning up...
  Removing temporary dir /private/tmp/pip_build_root...
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 283, in run
    requirement_set.install(install_options, global_options, root=options.root_path)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1431, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 598, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1836, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 295, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-ZBkEd1-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

Remove quotes from request

First, I love to tool. Seems like a much less painful way to do some ad hoc testing during dev.

So I am trying to submit a request using JWT authorization. It looks like Httpie has a plugin for this, but I am trying to get it working without that. The problem is that the request still includes quotation marks that causes it to fail

http-prompt localhost/api/account

Authorization:'Bearer <jwt>'
get

What I want is

Authorization: Bearer <jwt>

But according to my logs I am getting

Authorization: 'Bearer <jwt>'

Any suggestions?

multiple querystring params ignored

Httpie supports sending multiple querystring args with the same key. http-prompt uses a dict behind the scenes and therefore only calls Httpie with a single value:

http://localhost:6543/testing> httpie get par==1 par==2
http GET http://localhost:6543/testing par==2

This should result in:

http://localhost:6543/testing> httpie get par==1 par==2
http GET http://localhost:6543/testing par==1 par==2

Escaping querystring is not working

I have colon (:) in my query string and escaping the colon is not working as expected. The query works in httpie.

debug output:

http://localhost:3000/games> get 'where[id\:gt]:=2'
HTTPie 0.9.9
Requests 2.13.0
Pygments 2.2.0
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609]
/usr/bin/python
Linux 4.4.0-59-generic

<Environment {
    "colors": 256, 
    "config": {
        "__meta__": {
            "about": "u'HTTPie configuration file'", 
            "help": "u'https://github.com/jkbrzt/httpie#config'", 
            "httpie": "u'0.9.4'"
        }, 
        "default_options": "[]"
    }, 
    "config_dir": "/home/kishan/.httpie", 
    "is_windows": false, 
    "stderr": "<open file '<stderr>', mode 'w' at 0x7fac21dbb1e0>", 
    "stderr_isatty": true, 
    "stdin": "<open file '<stdin>', mode 'r' at 0x7fac21dbb0c0>", 
    "stdin_encoding": "UTF-8", 
    "stdin_isatty": true, 
    "stdout": "<http_prompt.output.Printer object at 0x7fac1b3ce790>", 
    "stdout_encoding": "utf8", 
    "stdout_isatty": true
}>

>>> requests.request(**{
    "allow_redirects": false, 
    "auth": "None", 
    "cert": "None", 
    "data": {}, 
    "files": {}, 
    "headers": {
        "User-Agent": "HTTPie/0.9.9", 
        "where[id": "gt]:=2"
    }, 
    "method": "u'get'", 
    "params": {}, 
    "proxies": {}, 
    "stream": true, 
    "timeout": 30, 
    "url": "u'http://localhost:3000/games'", 
    "verify": true
})


http: error: ConnectionError: ('Connection aborted.', BadStatusLine("''",)) while doing GET request to URL: http://localhost:3000/games
('Connection aborted.', BadStatusLine("''",))

Crash using umlauts in "User-Agent" string.

$ http-prompt www.orf.at
Version: 0.9.0
http://www.orf.at> User-Agent:"Ö"
Traceback (most recent call last):
File "/home/user/.local/bin/http-prompt", line 11, in
sys.exit(cli())
File "/usr/local/lib/python2.7/dist-packages/click-6.6-py2.7.egg/click/core.py", line 716, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/click-6.6-py2.7.egg/click/core.py", line 696, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/dist-packages/click-6.6-py2.7.egg/click/core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/dist-packages/click-6.6-py2.7.egg/click/core.py", line 534, in invoke
return callback(*args, **kwargs)
File "/home/user/.local/lib/python2.7/site-packages/http_prompt/cli.py", line 129, in cli
execute(text, context, listener=listener)
File "/home/user/.local/lib/python2.7/site-packages/http_prompt/execution.py", line 522, in execute
click.secho(str(err), err=True, fg='red')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xd6' in position 166: ordinal not in range(128)

Support for sending body data that isn't in key:value format

We should support somehow sending request body data as raw string. Without the requirement of providing key=value pair. This is related to httpie/cli#399 . In the httpie library, the issue is solved by command input redirection... Eg.:

echo 'some string value' | http POST example.com/person/1

Which sort of complicates things for this library... I'm not sure how we should approach this.

Add 'reset' Command

Hey @eliangcs !

Awesome tool. I'm clearly going to get a lot of use out of this. I'm going to file a bunch of tickets now as feature requests. I'm sure you've thought about lots of these, but if we have them as individual Issues then we can discuss them/track changes/assign them, etc.

The first would be a simple 'reset' command. I like the current default behavior that 'name=jack' will persist, but I'd like to be able to reset it with a single command.

Remote end closed connection without response

http-prompt stopped working for a particular webapp after some refactoring. I can curl or use http(httpie) to get data from the same endpoint, but http-prompt fails with:

Version: 0.4.2
http://localhost:3000> cd api/movies
http://localhost:3000/api/movies> get
HTTPie 0.9.4
Requests 2.10.0
Pygments 2.1.3
Python 3.5.1+ (default, Mar 30 2016, 22:46:26) 
[GCC 5.3.1 20160330]
/home/kishan/.virtualenvs/elasticsearch/bin/python3
Linux 4.4.0-31-generic

<Environment {
    "colors": 256,
    "config": {
        "__meta__": {
            "about": "HTTPie configuration file",
            "help": "https://github.com/jkbrzt/httpie#config",
            "httpie": "0.9.4"
        },
        "default_options": "[]"
    },
    "config_dir": "/home/kishan/.httpie",
    "is_windows": false,
    "stderr": "<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>",
    "stderr_isatty": true,
    "stdin": "<_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>",
    "stdin_encoding": "UTF-8",
    "stdin_isatty": true,
    "stdout": "<_io.BytesIO object at 0x7f15209f3fc0>",
    "stdout_encoding": "utf8",
    "stdout_isatty": true
}>

>>> requests.request(**{
    "allow_redirects": false,
    "auth": "None",
    "cert": "None",
    "data": "{\"type\": \"1\"}",
    "files": {},
    "headers": {
        "Accept": "application/json",
        "Content-Type": "application/json",
        "User-Agent": "HTTPie/0.9.4",
        "where[name": "search]==Aparajito"
    },
    "method": "get",
    "params": {},
    "proxies": {},
    "stream": true,
    "timeout": 30,
    "url": "http://localhost:3000/api/movies",
    "verify": true
})


http: error: ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',)) while doing GET request to URL: http://localhost:3000/api/movies
ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))

Parse tree:
<Node called "immutation" matching "get">  <-- *** We were here. ***
    <Node called "action" matching "get">
        <RegexNode called "_" matching "">
        <Node called "method" matching "get">
            <RegexNode matching "get">
        <RegexNode called "_" matching "">
        <Node matching "">
        <Node matching "">

This is only happening for a particular node web server. For my other applications, it's working as expected. The reason I'm confused why this is happening is because using httpie with http :3000/api/movies returns the results without any error.

Also notice there's a phantom request body containing {type: 1} which was not sent but yet somehow appeared to the request.

http-prompt immediately exits upon receiving an interrupt without prompting for confirmation

I find myself exiting the program accidentally very often.

When using a shell like bash, I will often use Ctrl-C interrupts to abort my current prompt and start again. It would be super cool if http-prompt worked the same way.

Currently, an interrupt will exit the program without confirmation. That is problematic because my natural inclination when making a typo in a prompt is to Ctrl-C and retype it.

Using interrupts to exit is still fine, as long as it has some form of confirmation first. Other shells do things like:

  • Press Ctrl-C twice in a row to exit
  • Ask for a confirmation (Yn)

Also common is for an interrupt to just start a fresh prompt, which is what I would personally prefer.

help and dummy command

A nice to have would be to have an help command.

Another thing is that just pressing enter return Syntax error near "" it should do nothing in my opinion

Question: Storing cookies

Hi, nice app!
Can http-prompt store cookies automatically from a response like this?

Set-Cookie: author=f0a117c7-75a4-4abe-8617-1d3d06c4d2a7; path=/; httponly
Set-Cookie: author.sig=y4Kfr_MNE7RJmeL1x6vLhixHUAo; path=/; httponly

What I do now is copy/pasting (a bit painful):

Cookie:author=f0a117c7-75a4-4abe-8617-1d3d06c4d2a7;author.sig=y4Kfr_MNE7RJmeL1x6vLhixHUAo;

Excessive leading newlines after the response headers and body

In http-prompt my response headers and bodies are leaded with excessive newlines.
(0.7.0, downloaded with pip)

http-vs-http-status

When calling the same resource from just http it prints correctly.
I also tried changing the pager from less to more in the config which didn't change anything.
The newlines don't appear when scrolling through a large response with less.

Here's how the response looks with curl:

curl-raw

It seems to happen independently to both the headers and the body:

headers-body

History support

If I exit the prompt and start back, previous options no longer available, I have to start all over again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.