"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docs/README.md" between
httpie-3.0.0.tar.gz and httpie-3.0.1.tar.gz

About: HTTPie is a command line HTTP client, a user-friendly cURL replacement, with the goal to make CLI interaction with web services as human-friendly as possible.

README.md  (httpie-3.0.0):README.md  (httpie-3.0.1)
skipping to change at line 541 skipping to change at line 541
``` ```
## Request items ## Request items
There are a few different *request item* types that provide a convenient There are a few different *request item* types that provide a convenient
mechanism for specifying HTTP headers, JSON and form data, files, mechanism for specifying HTTP headers, JSON and form data, files,
and URL parameters. This is a very practical way of constructing and URL parameters. This is a very practical way of constructing
HTTP requests from scratch on the CLI. HTTP requests from scratch on the CLI.
Each *request item* is simply a key/value pair separated with the following Each *request item* is simply a key/value pair separated with the following
characters: `:` (headers), `=` (data field, e.g JSON, Form), `:=` (raw data fiel d) characters: `:` (headers), `=` (data field, e.g., JSON, form), `:=` (raw data fi eld)
`==` (query parameters), `@` (file upload). `==` (query parameters), `@` (file upload).
```bash ```bash
$ http PUT pie.dev/put \ $ http PUT pie.dev/put \
X-Date:today \ # Header X-Date:today \ # Header
token==secret \ # Query parameter token==secret \ # Query parameter
name=John \ # Data field name=John \ # Data field
age:=29 # Raw JSON age:=29 # Raw JSON
``` ```
| Item Type | Description | | Item Type | Description |
| -----------------------------------------------------------: | --------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --------------------------------------- | |-------------------------------------------------------------:|---------------- -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- ----------------------------------------|
| HTTP Headers `Name:Value` | Arbitrary HTTP header, e.g. `X-API-Token:123` | | HTTP Headers `Name:Value` | Arbitrary HTTP header, e.g. `X-API-Token:123` |
| URL parameters `name==value` | Appends the giv en name/value pair as a querystring parameter to the URL. The `==` separator is used. | | URL parameters `name==value` | Appends the giv en name/value pair as a querystring parameter to the URL. The `==` separator is used. |
| Data Fields `field=value` | Request data fi elds to be serialized as a JSON object (default), to be form-encoded (with `--fo rm, -f`), or to be serialized as `multipart/form-data` (with `--multipart`) | | Data Fields `field=value` | Request data fi elds to be serialized as a JSON object (default), to be form-encoded (with `--fo rm, -f`), or to be serialized as `multipart/form-data` (with `--multipart`) |
| Raw JSON fields `field:=json` | Useful when sen ding JSON and one or more fields need to be a `Boolean`, `Number`, nested `Objec t`, or an `Array`, e.g., `meals:='["ham","spam"]'` or `pies:=[1,2,3]` (note the quotes) | | Raw JSON fields `field:=json` | Useful when sen ding JSON and one or more fields need to be a `Boolean`, `Number`, nested `Objec t`, or an `Array`, e.g., `meals:='["ham","spam"]'` or `pies:=[1,2,3]` (note the quotes) |
| File upload fields `field@/dir/file`, `field@file;type=mime` | Only available with `--form`, `-f` and `--multipart`. For example `screenshot@~/Pictures/img.pn g`, or `'cv@cv.txt;type=text/markdown'`. With `--form`, the presence of a file f ield results in a `--multipart` request | | File upload fields `field@/dir/file`, `field@file;type=mime` | Only available with `--form`, `-f` and `--multipart`. For example `screenshot@~/Pictures/img.pn g`, or `'cv@cv.txt;type=text/markdown'`. With `--form`, the presence of a file f ield results in a `--multipart` request |
Note that the structured data fields aren’t the only way to specify request data : Note that the structured data fields aren’t the only way to specify request data :
[raw request body](#raw-request-body) is a mechanism for passing arbitrary reque st data. [raw request body](#raw-request-body) is a mechanism for passing arbitrary reque st data.
### File based separators ### File based separators
Using file contents as values for specific fields is a very common use case, whi ch can be achieved through adding the `@` suffix to Using file contents as values for specific fields is a very common use case, whi ch can be achieved through adding the `@` suffix to
the operators above. For example instead of using a static string as the value f or some header, you can use `:@` operator the operators above. For example instead of using a static string as the value f or some header, you can use `:@` operator
to pass the desired value from a file. to pass the desired value from a file.
```bash ```bash
$ http POST pie.dev/post \ $ http POST pie.dev/post \
X-Data:@files/text.txt # Read a header from a file X-Data:@files/text.txt # Read a header from a file
token==@files/text.txt # Read a query parameter from a file token==@files/text.txt # Read a query parameter from a file
name=@files/text.txt # Read a data field's value from a file name=@files/text.txt # Read a data fields value from a file
bookmarks:=@files/data.json # Embed a JSON object from a file bookmarks:=@files/data.json # Embed a JSON object from a file
``` ```
### Escaping rules ### Escaping rules
You can use `\` to escape characters that shouldn’t be used as separators (or pa rts thereof). For instance, `foo\==bar` will become a data key/value pair (`foo= ` and `bar`) instead of a URL parameter. You can use `\` to escape characters that shouldn’t be used as separators (or pa rts thereof). For instance, `foo\==bar` will become a data key/value pair (`foo= ` and `bar`) instead of a URL parameter.
Often it is necessary to quote the values, e.g. `foo='bar baz'`. Often it is necessary to quote the values, e.g. `foo='bar baz'`.
If any of the field names or headers starts with a minus (e.g. `-fieldname`), yo u need to place all such items after the special token `--` to prevent confusion with `--arguments`: If any of the field names or headers starts with a minus (e.g. `-fieldname`), yo u need to place all such items after the special token `--` to prevent confusion with `--arguments`:
skipping to change at line 684 skipping to change at line 684
``` ```
The `:=`/`:=@` syntax is JSON-specific. You can switch your request to `--form` or `--multipart`, The `:=`/`:=@` syntax is JSON-specific. You can switch your request to `--form` or `--multipart`,
and string, float, and number values will continue to be serialized (as string f orm values). and string, float, and number values will continue to be serialized (as string f orm values).
Other JSON types, however, are not allowed with `--form` or `--multipart`. Other JSON types, however, are not allowed with `--form` or `--multipart`.
### Nested JSON ### Nested JSON
If your use case involves sending complex JSON objects as part of the request bo dy, If your use case involves sending complex JSON objects as part of the request bo dy,
HTTPie can help you build them right from your terminal. You still use the exist ing HTTPie can help you build them right from your terminal. You still use the exist ing
data field operators (`=`/`:=`) but instead of specifying a top-level field name (like `key=value`), you specify a path declaration. This tells HTTPie where and how to put the given value inside of an object. data field operators (`=`/`:=`) but instead of specifying a top-level field name (like `key=value`), you specify a path declaration. This tells HTTPie where and how to put the given value inside an object.
#### Introduction #### Introduction
Let's start with a simple example, and build a simple search query: Lets start with a simple example, and build a simple search query:
```bash ```bash
$ http --offline --print=B pie.dev/post \ $ http --offline --print=B pie.dev/post \
category=tools \ category=tools \
search[type]=id \ search[type]=id \
search[id]:=1 search[id]:=1
``` ```
In the example above, the `search[type]` is an instruction for creating an objec t called `search`, and setting the `type` field of it to the given value (`"id"` ). In the example above, the `search[type]` is an instruction for creating an objec t called `search`, and setting the `type` field of it to the given value (`"id"` ).
Also note that, just as the regular syntax, you can use the `:=` operator to dir ectly pass raw JSON values (e.g numbers in the case above). Also note that, just as the regular syntax, you can use the `:=` operator to dir ectly pass raw JSON values (e.g, numbers in the case above).
```json ```json
{ {
"category": "tools", "category": "tools",
"search": { "search": {
"id": 1, "id": 1,
"type": "id" "type": "id"
} }
} }
``` ```
skipping to change at line 810 skipping to change at line 810
"Terminal", "Terminal",
"Desktop", "Desktop",
"Web", "Web",
"Mobile" "Mobile"
], ],
"type": "platforms" "type": "platforms"
} }
} }
``` ```
And just to demonstrate all of these features together, let's create a very deep ly nested JSON object: And just to demonstrate all of these features together, lets create a very deep ly nested JSON object:
```bash ```bash
$ http PUT pie.dev/put \ $ http PUT pie.dev/put \
shallow=value \ # Shallow key-value pair shallow=value \ # Shallow key-value pair
object[key]=value \ # Nested key-value pair object[key]=value \ # Nested key-value pair
array[]:=1 \ # Array — first item array[]:=1 \ # Array — first item
array[1]:=2 \ # Array — second item array[1]:=2 \ # Array — second item
array[2]:=3 \ # Array — append (third item) array[2]:=3 \ # Array — append (third item)
very[nested][json][3][httpie][power][]=Amaze # Nested object very[nested][json][3][httpie][power][]=Amaze # Nested object
``` ```
skipping to change at line 848 skipping to change at line 848
```json ```json
{ {
"baz": { "baz": {
"[": 2, "[": 2,
"]": 3 "]": 3
}, },
"foo[bar]": 1 "foo[bar]": 1
} }
``` ```
If you want the send the literal backslash character (`\`), escape it with anoth er backslash: If you want to send the literal backslash character (`\`), escape it with anothe r backslash:
```bash ```bash
$ http --offline --print=B pie.dev/post \ $ http --offline --print=B pie.dev/post \
'backslash[\\]:=1' 'backslash[\\]:=1'
``` ```
```json ```json
{ {
"backslash": { "backslash": {
"\\": 1 "\\": 1
skipping to change at line 906 skipping to change at line 906
```console ```console
HTTPie Syntax Error: Expecting ']' HTTPie Syntax Error: Expecting ']'
foo[baz][quux foo[baz][quux
^ ^
``` ```
You can follow to given instruction (adding a `]`) and repair your expression. You can follow to given instruction (adding a `]`) and repair your expression.
##### Type safety ##### Type safety
Each container path (e.g `x[y][z]` in `x[y][z][1]`) has a certain type, which ge Each container path (e.g., `x[y][z]` in `x[y][z][1]`) has a certain type, which
ts defined with gets defined with
the first usage and can't be changed after that. If you try to do a key-based ac the first usage and can’t be changed after that. If you try to do a key-based ac
cess to an array or cess to an array or
an index-based access to an object, HTTPie will error out: an index-based access to an object, HTTPie will error out:
```bash ```bash
$ http --offline --print=B pie.dev/post \ $ http --offline --print=B pie.dev/post \
'array[]:=1' \ 'array[]:=1' \
'array[]:=2' \ 'array[]:=2' \
'array[key]:=3' 'array[key]:=3'
HTTPie Type Error: Can't perform 'key' based access on 'array' which has a type of 'array' but this operation requires a type of 'object'. HTTPie Type Error: Can't perform 'key' based access on 'array' which has a type of 'array' but this operation requires a type of 'object'.
array[key] array[key]
^^^^^ ^^^^^
skipping to change at line 1013 skipping to change at line 1013
--c31279ab254f40aeb06df32b433cbccb --c31279ab254f40aeb06df32b433cbccb
Content-Disposition: form-data; name="hello" Content-Disposition: form-data; name="hello"
world world
--c31279ab254f40aeb06df32b433cbccb-- --c31279ab254f40aeb06df32b433cbccb--
``` ```
File uploads are always streamed to avoid memory issues with large files. File uploads are always streamed to avoid memory issues with large files.
By default, HTTPie uses a random unique string as the multipart boundary but you can use `--boundary` to specify a custom string instead: By default, HTTPie uses a random unique string as the multipart boundary, but yo u can use `--boundary` to specify a custom string instead:
```bash ```bash
$ http --form --multipart --boundary=xoxo --offline example.org hello=world $ http --form --multipart --boundary=xoxo --offline example.org hello=world
``` ```
```http ```http
POST / HTTP/1.1 POST / HTTP/1.1
Content-Length: 129 Content-Length: 129
Content-Type: multipart/form-data; boundary=xoxo Content-Type: multipart/form-data; boundary=xoxo
Host: example.org Host: example.org
skipping to change at line 1107 skipping to change at line 1107
```bash ```bash
$ http pie.dev/headers Accept: User-Agent: $ http pie.dev/headers Accept: User-Agent:
``` ```
To send a header with an empty value, use `Header;`, with a semicolon: To send a header with an empty value, use `Header;`, with a semicolon:
```bash ```bash
$ http pie.dev/headers 'Header;' $ http pie.dev/headers 'Header;'
``` ```
Please note that some internal headers, such as `Content-Length`, can't be unset if Please note that some internal headers, such as `Content-Length`, cant be unset if
they are automatically added by the client itself. they are automatically added by the client itself.
### Multiple header values with the same name ### Multiple header values with the same name
If the request is sent with multiple headers that are sharing the same name, the n If the request is sent with multiple headers that are sharing the same name, the n
the HTTPie will send them individually. the HTTPie will send them individually.
```bash ```bash
http --offline example.org Cookie:one Cookie:two http --offline example.org Cookie:one Cookie:two
``` ```
skipping to change at line 1177 skipping to change at line 1177
$ http --offline POST pie.dev/post hello=world > request.http $ http --offline POST pie.dev/post hello=world > request.http
``` ```
```bash ```bash
# 2. send it over the wire with, for example, the fantastic netcat tool: # 2. send it over the wire with, for example, the fantastic netcat tool:
$ nc pie.dev 80 < request.http $ nc pie.dev 80 < request.http
``` ```
You can also use the `--offline` mode for debugging and exploring HTTP and HTTPi e, and for “dry runs”. You can also use the `--offline` mode for debugging and exploring HTTP and HTTPi e, and for “dry runs”.
`--offline` has the side-effect of automatically activating `--print=HB`, i.e., both the request headers and the body `--offline` has the side effect of automatically activating `--print=HB`, i.e., both the request headers and the body
are printed. You can customize the output with the usual [output options](#outpu t-options), with the exception where there are printed. You can customize the output with the usual [output options](#outpu t-options), with the exception where there
is no response to be printed. You can use `--offline` in combination with all th e other options (e.g. `--session`). is no response to be printed. You can use `--offline` in combination with all th e other options (e.g. `--session`).
## Cookies ## Cookies
HTTP clients send cookies to the server as regular [HTTP headers](#http-headers) . HTTP clients send cookies to the server as regular [HTTP headers](#http-headers) .
That means, HTTPie does not offer any special syntax for specifying cookies — th e usual `Header:Value` notation is used: That means, HTTPie does not offer any special syntax for specifying cookies — th e usual `Header:Value` notation is used:
Send a single cookie: Send a single cookie:
skipping to change at line 1441 skipping to change at line 1441
Note: these cipher strings do not change the negotiated version of SSL or TLS, t hey only affect the list of available cipher suites. Note: these cipher strings do not change the negotiated version of SSL or TLS, t hey only affect the list of available cipher suites.
To see the default cipher string, run `http --help` and see the `--ciphers` sect ion under SSL. To see the default cipher string, run `http --help` and see the `--ciphers` sect ion under SSL.
## Output options ## Output options
By default, HTTPie only outputs the final response and the whole response By default, HTTPie only outputs the final response and the whole response
message is printed (headers as well as the body). You can control what should message is printed (headers as well as the body). You can control what should
be printed via several options: be printed via several options:
| Option | What is printed | Option | What is printed
| |
| -------------------------: | ------------------------------------------------- |---------------------------:|--------------------------------------------------
------------------------------------------------- | --------------------------------------------------|
| `--headers, -h` | Only the response headers are printed | `--headers, -h` | Only the response headers are printed
| |
| `--body, -b` | Only the response body is printed | `--body, -b` | Only the response body is printed
| |
| `--meta, -m` | Only the response metadata is printed (various me | `--meta, -m` | Only the response metadata is printed (various me
trics like total elapsed time) | trics like total elapsed time) |
| `--verbose, -v` | Print the whole HTTP exchange (request and respon | `--verbose, -v` | Print the whole HTTP exchange (request and respon
se). This option also enables `--all` (see below) | se). This option also enables `--all` (see below) |
| `--verbose --verbose, -vv` | Just like `-v`, but also include the response met adata. | | `--verbose --verbose, -vv` | Just like `-v`, but also include the response met adata. |
| `--print, -p` | Selects parts of the HTTP exchange | `--print, -p` | Selects parts of the HTTP exchange
| |
| `--quiet, -q` | Don't print anything to `stdout` and `stderr` | `--quiet, -q` | Don’t print anything to `stdout` and `stderr`
| |
### What parts of the HTTP exchange should be printed ### What parts of the HTTP exchange should be printed
All the other [output options](#output-options) are under the hood just shortcut s for the more powerful `--print, -p`. All the other [output options](#output-options) are under the hood just shortcut s for the more powerful `--print, -p`.
It accepts a string of characters each of which represents a specific part of th e HTTP exchange: It accepts a string of characters each of which represents a specific part of th e HTTP exchange:
| Character | Stands for | | Character | Stands for |
| --------: | ---------------- | |----------:|------------------|
| `H` | request headers | | `H` | request headers |
| `B` | request body | | `B` | request body |
| `h` | response headers | | `h` | response headers |
| `b` | response body | | `b` | response body |
| `m` | response meta | | `m` | response meta |
Print request and response headers: Print request and response headers:
```bash ```bash
$ http --print=Hh PUT pie.dev/put hello=world $ http --print=Hh PUT pie.dev/put hello=world
``` ```
#### Response meta
The response metadata section currently includes the total time elapsed. It’s th
e number of seconds between opening the network connection and downloading the l
ast byte of response the body.
Please note that it also includes time spent on formatting the output, which add
s a small penalty. Also, if the body is not part of the output, we don’t spend t
ime downloading it — please see [conditional body download](#conditional-body-do
wnload).
If you [use `--style` with one of the Pie themes](#colors-and-formatting), you’l
l see the time information color-coded (green/orange/red) based on how long the
exchange took.
### Verbose output ### Verbose output
`--verbose` can often be useful for debugging the request and generating documen tation examples: `--verbose` can often be useful for debugging the request and generating documen tation examples:
```bash ```bash
$ http --verbose PUT pie.dev/put hello=world $ http --verbose PUT pie.dev/put hello=world
PUT /put HTTP/1.1 PUT /put HTTP/1.1
Accept: application/json, */*;q=0.5 Accept: application/json, */*;q=0.5
Accept-Encoding: gzip, deflate Accept-Encoding: gzip, deflate
Content-Type: application/json Content-Type: application/json
skipping to change at line 1631 skipping to change at line 1639
- call parents - call parents
^D ^D
``` ```
On macOS, you can send the contents of the clipboard with `pbpaste`: On macOS, you can send the contents of the clipboard with `pbpaste`:
```bash ```bash
$ pbpaste | http PUT pie.dev/put $ pbpaste | http PUT pie.dev/put
``` ```
Passing data through `stdin` **can't** be combined with data fields specified on the command line: Passing data through `stdin` **cant** be combined with data fields specified on the command line:
```bash ```bash
$ echo -n 'data' | http POST example.org more=data # This is invalid $ echo -n 'data' | http POST example.org more=data # This is invalid
``` ```
To prevent HTTPie from reading `stdin` data you can use the `--ignore-stdin` opt ion. To prevent HTTPie from reading `stdin` data you can use the `--ignore-stdin` opt ion.
### Request data via `--raw` ### Request data via `--raw`
In a situation when piping data via `stdin` is not convenient (for example, In a situation when piping data via `stdin` is not convenient (for example,
skipping to change at line 1714 skipping to change at line 1722
## Terminal output ## Terminal output
HTTPie does several things by default in order to make its terminal output easy to read. HTTPie does several things by default in order to make its terminal output easy to read.
### Colors and formatting ### Colors and formatting
Syntax highlighting is applied to HTTP headers and bodies (where it makes sense) . Syntax highlighting is applied to HTTP headers and bodies (where it makes sense) .
You can choose your preferred color scheme via the `--style` option if you don’t like the default one. You can choose your preferred color scheme via the `--style` option if you don’t like the default one.
There are dozens of styles available, here are just a few notable ones: There are dozens of styles available, here are just a few notable ones:
| Style | Description | Style | Description
|
| ---------: | -----------------------------------------------------------------
------------------------------------------------------------------- | |
| `auto` | Follows your terminal ANSI color styles. This is the default styl |------------:|-----------------------------------------------------------------
e used by HTTPie | --------------------------------------------------------------------------------
| `default` | Default styles of the underlying Pygments library. Not actually u --------------------------------------------------------------------------------
sed by default by HTTPie. You can enable it with `--style=default` | ----------------------------|
| `pie-dark` | HTTPie’s original brand style. Also used in [HTTPie for Web and D | `auto` | Follows your terminal ANSI color styles. This is the default sty
esktop](https://httpie.io/product). le used by HTTPie
|
|`pie-light` | Like `pie-dark`, but for terminals with light background colors. |
| | `default` | Default styles of the underlying Pygments library. Not actually
| `pie` | A generic version of `pie-dark` and `pie-light` themes that can w used by default by HTTPie. You can enable it with `--style=default`
ork with any terminal background. Its universality requires compromises in terms
of legibility, but it’s useful if you frequently switch your terminal between d |
ark and light backgrounds. | | `pie-dark` | HTTPie’s original brand style. Also used in [HTTPie for Web and
| `monokai` | A popular color scheme. Enable with `--style=monokai` Desktop](https://httpie.io/product).
|
| `fruity` | A bold, colorful scheme. Enable with `--style=fruity` |
| | `pie-light` | Like `pie-dark`, but for terminals with light background colors.
| … | See `$ http --help` for all the possible `--style` values
|
|
| `pie` | A generic version of `pie-dark` and `pie-light` themes that can
work with any terminal background. Its universality requires compromises in term
s of legibility, but it’s useful if you frequently switch your terminal between
dark and light backgrounds. |
| `monokai` | A popular color scheme. Enable with `--style=monokai`
|
| `fruity` | A bold, colorful scheme. Enable with `--style=fruity`
|
| … | See `$ http --help` for all the possible `--style` values
|
Use one of these options to control output processing: Use one of these options to control output processing:
| Option | Description | | Option | Description |
| ----------------: | ---------------------------------------------------------- --- | |------------------:|----------------------------------------------------------- ----|
| `--pretty=all` | Apply both colors and formatting. Default for terminal out put | | `--pretty=all` | Apply both colors and formatting. Default for terminal out put |
| `--pretty=colors` | Apply colors | | `--pretty=colors` | Apply colors |
| `--pretty=format` | Apply formatting | | `--pretty=format` | Apply formatting |
| `--pretty=none` | Disables output processing. Default for redirected output | | `--pretty=none` | Disables output processing. Default for redirected output |
HTTPie looks at `Content-Type` to select the right syntax highlighter and format ter for each message body. If that fails (e.g., the server provides the wrong ty pe), or you prefer a different treatment, you can manually overwrite the mime ty pe for a response with `--response-mime`: HTTPie looks at `Content-Type` to select the right syntax highlighter and format ter for each message body. If that fails (e.g., the server provides the wrong ty pe), or you prefer a different treatment, you can manually overwrite the mime ty pe for a response with `--response-mime`:
```bash ```bash
$ http --response-mime=text/yaml pie.dev/get $ http --response-mime=text/yaml pie.dev/get
``` ```
Formatting has the following effects: Formatting has the following effects:
- HTTP headers are sorted by name. - HTTP headers are sorted by name.
- JSON data is indented, sorted by keys, and unicode escapes are converted - JSON data is indented, sorted by keys, and unicode escapes are converted
to the characters they represent. to the characters they represent.
- XML and XHTML data is indented. - XML and XHTML data is indented.
Please note that sometimes there might be changes made by formatters on the actu al response body (e.g Please note that sometimes there might be changes made by formatters on the actu al response body (e.g.,
collapsing empty tags on XML) but the end result will always be semantically ind istinguishable. Some of collapsing empty tags on XML) but the end result will always be semantically ind istinguishable. Some of
these formatting changes can be configured more granularly through [format optio ns](#format-options). these formatting changes can be configured more granularly through [format optio ns](#format-options).
### Format options ### Format options
The `--format-options=opt1:value,opt2:value` option allows you to control how th e output should be formatted The `--format-options=opt1:value,opt2:value` option allows you to control how th e output should be formatted
when formatting is applied. The following options are available: when formatting is applied. The following options are available:
| Option | Default value | Shortcuts | | Option | Default value | Shortcuts |
| ---------------: | :-----------: | ------------------------ | |-----------------:|:-------------:|--------------------------|
| `headers.sort` | `true` | `--sorted`, `--unsorted` | | `headers.sort` | `true` | `--sorted`, `--unsorted` |
| `json.format` | `true` | N/A | | `json.format` | `true` | N/A |
| `json.indent` | `4` | N/A | | `json.indent` | `4` | N/A |
| `json.sort_keys` | `true` | `--sorted`, `--unsorted` | | `json.sort_keys` | `true` | `--sorted`, `--unsorted` |
| `xml.format` | `true` | N/A | | `xml.format` | `true` | N/A |
| `xml.indent` | `2` | N/A | | `xml.indent` | `2` | N/A |
For example, this is how you would disable the default header and JSON key For example, this is how you would disable the default header and JSON key
sorting, and specify a custom JSON indent size: sorting, and specify a custom JSON indent size:
skipping to change at line 1906 skipping to change at line 1914
`-dco` is shorthand for `--download` `--continue` `--output`. `-dco` is shorthand for `--download` `--continue` `--output`.
### Other notes ### Other notes
- The `--download` option only changes how the response body is treated. - The `--download` option only changes how the response body is treated.
- You can still set custom headers, use sessions, `--verbose, -v`, etc. - You can still set custom headers, use sessions, `--verbose, -v`, etc.
- `--download` always implies `--follow` (redirects are followed). - `--download` always implies `--follow` (redirects are followed).
- `--download` also implies `--check-status` (error HTTP status will result in a non-zero exist static code). - `--download` also implies `--check-status` (error HTTP status will result in a non-zero exist static code).
- HTTPie exits with status code `1` (error) if the body hasn’t been fully downlo aded. - HTTPie exits with status code `1` (error) if the body hasn’t been fully downlo aded.
- `Accept-Encoding` can't be set with `--download`. - `Accept-Encoding` cant be set with `--download`.
## Streamed responses ## Streamed responses
Responses are downloaded and printed in chunks. Responses are downloaded and printed in chunks.
This allows for streaming and large file downloads without using too much memory . This allows for streaming and large file downloads without using too much memory .
However, when [colors and formatting](#colors-and-formatting) are applied, the w hole response is buffered and only then processed at once. However, when [colors and formatting](#colors-and-formatting) are applied, the w hole response is buffered and only then processed at once.
### Disabling buffering ### Disabling buffering
You can use the `--stream, -S` flag to make two things happen: You can use the `--stream, -S` flag to make two things happen:
skipping to change at line 1985 skipping to change at line 1993
``` ```
To create or reuse a different session, simply specify a different name: To create or reuse a different session, simply specify a different name:
```bash ```bash
$ http --session=user2 -a user2:password pie.dev/get X-Bar:Foo $ http --session=user2 -a user2:password pie.dev/get X-Bar:Foo
``` ```
Named sessions’ data is stored in JSON files inside the `sessions` subdirectory of the [config](#config) directory, typically `~/.config/httpie/sessions/<host>/ <name>.json` (`%APPDATA%\httpie\sessions\<host>\<name>.json` on Windows). Named sessions’ data is stored in JSON files inside the `sessions` subdirectory of the [config](#config) directory, typically `~/.config/httpie/sessions/<host>/ <name>.json` (`%APPDATA%\httpie\sessions\<host>\<name>.json` on Windows).
If you have executed the above commands on a Unix machine, you should be able li st the generated sessions files using: If you have executed the above commands on a Unix machine, you should be able to list the generated sessions files using:
```bash ```bash
$ ls -l ~/.config/httpie/sessions/pie.dev $ ls -l ~/.config/httpie/sessions/pie.dev
``` ```
### Anonymous sessions ### Anonymous sessions
Instead of giving it a name, you can also directly specify a path to a session f ile. Instead of giving it a name, you can also directly specify a path to a session f ile.
This allows for sessions to be re-used across multiple hosts: This allows for sessions to be re-used across multiple hosts:
skipping to change at line 2081 skipping to change at line 2089
For example, a cookie set through the command line will overwrite a cookie of th e same name stored in the session file. For example, a cookie set through the command line will overwrite a cookie of th e same name stored in the session file.
If the server returns a `Set-Cookie` header with a cookie of the same name, the returned cookie will overwrite the preexisting cookie. If the server returns a `Set-Cookie` header with a cookie of the same name, the returned cookie will overwrite the preexisting cookie.
Expired cookies are never stored. Expired cookies are never stored.
If a cookie in a session file expires, it will be removed before sending a new r equest. If a cookie in a session file expires, it will be removed before sending a new r equest.
If the server expires an existing cookie, it will also be removed from the sessi on file. If the server expires an existing cookie, it will also be removed from the sessi on file.
## Config ## Config
HTTPie uses a simple `config.json` file. HTTPie uses a simple `config.json` file.
The file doesn’t exist by default but you can create it manually. The file doesn’t exist by default, but you can create it manually.
### Config file directory ### Config file directory
To see the exact location for your installation, run `http --debug` and look for `config_dir` in the output. To see the exact location for your installation, run `http --debug` and look for `config_dir` in the output.
The default location of the configuration file on most platforms is `$XDG_CONFIG _HOME/httpie/config.json` (defaulting to `~/.config/httpie/config.json`). The default location of the configuration file on most platforms is `$XDG_CONFIG _HOME/httpie/config.json` (defaulting to `~/.config/httpie/config.json`).
For backwards compatibility, if the directory `~/.httpie` exists, the configurat ion file there will be used instead. For backwards compatibility, if the directory `~/.httpie` exists, the configurat ion file there will be used instead.
On Windows, the config file is located at `%APPDATA%\httpie\config.json`. On Windows, the config file is located at `%APPDATA%\httpie\config.json`.
skipping to change at line 2123 skipping to change at line 2131
```json ```json
{ {
"default_options": [ "default_options": [
"--style=fruity" "--style=fruity"
] ]
} }
``` ```
Technically, it is possible to include any HTTPie options in there. Technically, it is possible to include any HTTPie options in there.
However, it is not recommended to modify the default behavior in a way that woul d break your compatibility with the wider world as that may become confusing. However, it is not recommended modifying the default behavior in a way that woul d break your compatibility with the wider world as that may become confusing.
#### `plugins_dir` #### `plugins_dir`
The directory where the plugins will be installed. HTTPie needs to have read/wri te access on that directory, since The directory where the plugins will be installed. HTTPie needs to have read/wri te access on that directory, since
`httpie plugins install` will download new plugins to there. `httpie plugins install` will download new plugins to there.
### Un-setting previously specified options ### Un-setting previously specified options
Default options from the config file, or specified any other way, can be unset f or a particular invocation via `--no-OPTION` arguments passed via the command li ne (e.g., `--no-style` or `--no-session`). Default options from the config file, or specified any other way, can be unset f or a particular invocation via `--no-OPTION` arguments passed via the command li ne (e.g., `--no-style` or `--no-session`).
skipping to change at line 2188 skipping to change at line 2196
> the HTTPie project. We do not control / review them at the moment, so use them at your own discretion. > the HTTPie project. We do not control / review them at the moment, so use them at your own discretion.
For managing these plugins; starting with 3.0, we are offering a new plugin mana ger. For managing these plugins; starting with 3.0, we are offering a new plugin mana ger.
This command is currently in beta. This command is currently in beta.
### `httpie plugins` ### `httpie plugins`
`plugins` interface is a very simple plugin manager for installing, listing and uninstalling HTTPie plugins. `plugins` interface is a very simple plugin manager for installing, listing and uninstalling HTTPie plugins.
> In the past `pip` was used to install/uninstall plugins, but on some environme In the past `pip` was used to install/uninstall plugins, but on some environment
nts (e.g brew installed s (e.g., brew installed
packages) it wasn't working properly. The new interface is a very simple overlay packages) it wasn’t working properly. The new interface is a very simple overlay
on top of `pip` to allow on top of `pip` to allow
plugin installations on every installation method. plugin installations on every installation method.
> By default the plugins (and their missing dependencies) will be stored under t he configuration directory, By default, the plugins (and their missing dependencies) will be stored under th e configuration directory,
but this can be modified through `plugins_dir` variable on the config. but this can be modified through `plugins_dir` variable on the config.
#### `httpie plugins install` #### `httpie plugins install`
For installing plugins from [PyPI](https://pypi.org/) or from local paths, `http ie plugins install` For installing plugins from [PyPI](https://pypi.org/) or from local paths, `http ie plugins install`
can be used. can be used.
```bash ```bash
$ httpie plugins install httpie-plugin $ httpie plugins install httpie-plugin
Installing httpie-plugin... Installing httpie-plugin...
skipping to change at line 2235 skipping to change at line 2243
For upgrading already installed plugins, use `httpie plugins upgrade`. For upgrading already installed plugins, use `httpie plugins upgrade`.
```bash ```bash
$ httpie plugins upgrade httpie-plugin $ httpie plugins upgrade httpie-plugin
``` ```
#### `httpie plugins uninstall` #### `httpie plugins uninstall`
Uninstall plugins from the isolated plugins directory. If the plugin is not inst alled Uninstall plugins from the isolated plugins directory. If the plugin is not inst alled
through `httpie plugins install`, it won't uninstall it. through `httpie plugins install`, it wont uninstall it.
```bash ```bash
$ httpie plugins uninstall httpie-plugin $ httpie plugins uninstall httpie-plugin
``` ```
## Meta ## Meta
### Interface design ### Interface design
The syntax of the command arguments closely correspond to the actual HTTP reques ts sent over the wire. The syntax of the command arguments closely correspond to the actual HTTP reques ts sent over the wire.
 End of changes. 29 change blocks. 
70 lines changed or deleted 102 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)