"Fossies" - the Fresh Open Source Software Archive

Member "http-prompt-2.1.0/http_prompt/completion.py" (5 Mar 2021, 4686 Bytes) of package /linux/www/http-prompt-2.1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "completion.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.0.0_vs_2.1.0.

    1 """Meta data for autocomplete."""
    2 
    3 from collections import OrderedDict
    4 
    5 from . import options as opt
    6 
    7 
    8 ROOT_COMMANDS = OrderedDict([
    9     ('cd', 'Change URL/path'),
   10     ('clear', 'Clear console screen'),
   11     ('curl', 'Preview curl command'),
   12     ('env', 'Print environment'),
   13     ('exec', 'Clear and load environment from a file'),
   14     ('exit', 'Exit HTTP Prompt'),
   15     ('help', 'List commands, actions, and HTTPie options'),
   16     ('httpie', 'Preview HTTPie command'),
   17     ('rm *', 'Remove all options and parameters'),
   18     ('rm -b', 'Remove body parameter'),
   19     ('rm -b *', 'Remove all body parameters'),
   20     ('rm -h', 'Remove header'),
   21     ('rm -h *', 'Remove all headers'),
   22     ('rm -o', 'Remove HTTPie option'),
   23     ('rm -o *', 'Remove all HTTPie options'),
   24     ('rm -q', 'Remove querystring parameter'),
   25     ('rm -q *', 'Remove all querystring parameters'),
   26     ('source', 'Load environment from a file'),
   27 ])
   28 
   29 ACTIONS = OrderedDict([
   30     ('connect', 'CONNECT request'),
   31     ('delete', 'DELETE request'),
   32     ('get', 'GET request'),
   33     ('head', 'HEAD request'),
   34     ('options', 'OPTIONS request'),
   35     ('patch', 'GET request'),
   36     ('post', 'POST request'),
   37     ('put', 'PUT request'),
   38 ])
   39 
   40 # http://www.iana.org/assignments/message-headers/message-headers.xhtml
   41 # https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
   42 HEADER_NAMES = OrderedDict([
   43     ('Accept', 'Acceptable response media type'),
   44     ('Accept-Charset', 'Acceptable response charsets'),
   45     ('Accept-Encoding', 'Acceptable response content codings'),
   46     ('Accept-Language', 'Preferred natural languages in response'),
   47     ('ALPN', 'Application-layer protocol negotiation to use'),
   48     ('Alt-Used', 'Alternative host in use'),
   49     ('Authorization', 'Authentication information'),
   50     ('Cache-Control', 'Directives for caches'),
   51     ('Connection', 'Connection options'),
   52     ('Content-Encoding', 'Content codings'),
   53     ('Content-Language', 'Natural languages for content'),
   54     ('Content-Length', 'Anticipated size for payload body'),
   55     ('Content-Location', 'Where content was obtained'),
   56     ('Content-MD5', 'Base64-encoded MD5 sum of content'),
   57     ('Content-Type', 'Content media type'),
   58     ('Cookie', 'Stored cookies'),
   59     ('Date', 'Datetime when message was originated'),
   60     ('Depth', 'Applied only to resource or its members'),
   61     ('DNT', 'Do not track user'),
   62     ('Expect', 'Expected behaviors supported by server'),
   63     ('Forwarded', 'Proxies involved'),
   64     ('From', 'Sender email address'),
   65     ('Host', 'Target URI'),
   66     ('HTTP2-Settings', 'HTTP/2 connection parameters'),
   67     ('If', 'Request condition on state tokens and ETags'),
   68     ('If-Match', 'Request condition on target resource'),
   69     ('If-Modified-Since', 'Request condition on modification date'),
   70     ('If-None-Match', 'Request condition on target resource'),
   71     ('If-Range', 'Request condition on Range'),
   72     ('If-Schedule-Tag-Match', 'Request condition on Schedule-Tag'),
   73     ('If-Unmodified-Since', 'Request condition on modification date'),
   74     ('Max-Forwards', 'Max number of times forwarded by proxies'),
   75     ('MIME-Version', 'Version of MIME protocol'),
   76     ('Origin', 'Origin(s) issuing the request'),
   77     ('Pragma', 'Implementation-specific directives'),
   78     ('Prefer', 'Preferred server behaviors'),
   79     ('Proxy-Authorization', 'Proxy authorization credentials'),
   80     ('Proxy-Connection', 'Proxy connection options'),
   81     ('Range', 'Request transfer of only part of data'),
   82     ('Referer', 'Previous web page'),
   83     ('TE', 'Transfer codings willing to accept'),
   84     ('Transfer-Encoding', 'Transfer codings applied to payload body'),
   85     ('Upgrade', 'Invite server to upgrade to another protocol'),
   86     ('User-Agent', 'User agent string'),
   87     ('Via', 'Intermediate proxies'),
   88     ('Warning', 'Possible incorrectness with payload body'),
   89     ('WWW-Authenticate', 'Authentication scheme'),
   90     ('X-Csrf-Token', 'Prevent cross-site request forgery'),
   91     ('X-CSRFToken', 'Prevent cross-site request forgery'),
   92     ('X-Forwarded-For', 'Originating client IP address'),
   93     ('X-Forwarded-Host', 'Original host requested by client'),
   94     ('X-Forwarded-Proto', 'Originating protocol'),
   95     ('X-Http-Method-Override', 'Request method override'),
   96     ('X-Requested-With', 'Used to identify Ajax requests'),
   97     ('X-XSRF-TOKEN', 'Prevent cross-site request forgery'),
   98 ])
   99 
  100 CONTENT_TYPES = [
  101     'application/json',
  102     'application/x-www-form-urlencoded',
  103     'multipart/form-data',
  104     'text/html',
  105 ]
  106 
  107 # TODO: Include more common header values
  108 HEADER_VALUES = {
  109     'Accept': CONTENT_TYPES,
  110     'Content-Type': CONTENT_TYPES,
  111 }
  112 
  113 OPTION_NAMES = sorted(opt.FLAG_OPTIONS + opt.VALUE_OPTIONS)
  114 OPTION_NAMES = OrderedDict(OPTION_NAMES)