1
0
mirror of https://github.com/httpie/cli.git synced 2026-04-26 20:02:11 +02:00

Add the Snap build file for general Linux packaging

Based on the work of @elopio and @chipaca.

- Added support for the `snapd` protocol URL.
- Packaged Unix socket transport plugin.
This commit is contained in:
Mickaël Schoentgen
2021-07-02 17:03:23 +02:00
parent 1ef127c61d
commit cf21790411
2 changed files with 146 additions and 32 deletions
+38 -32
View File
@@ -57,7 +57,13 @@ $ port install httpie
### Linux
Most Linux distributions provide a package that can be installed using the
HTTPie is available on the [Snap Store](https://snapcraft.io/httpie):
```bash
$ snap install httpie
```
And most Linux distributions provide a package that can be installed using the
system package manager, for example:
```bash
@@ -351,12 +357,12 @@ There are a few different *request item* types that provide a convenient mechani
They are key/value pairs specified after the URL. All have in common that they become part of the actual request that is sent and that their type is distinguished only by the separator used: `:`, `=`, `:=`, `==`, `@`, `=@`, and `:=@`. The ones with an `@` expect a file path as value.
| Item Type | Description |
| Item Type | Description |
| -----------------------------------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| HTTP Headers `Name:Value` | Arbitrary HTTP header, e.g. `X-API-Token:123` |
| URL parameters `name==value` | Appends the given name/value pair as a querystring parameter to the URL. The `==` separator is used. |
| Data Fields `field=value`, `field=@file.txt` | Request data fields to be serialized as a JSON object (default), to be form-encoded (with `--form, -f`), or to be serialized as `multipart/form-data` (with `--multipart`) |
| Raw JSON fields `field:=json` | Useful when sending JSON and one or more fields need to be a `Boolean`, `Number`, nested `Object`, or an `Array`, e.g., `meals:='["ham","spam"]'` or `pies:=[1,2,3]` (note the quotes) |
| HTTP Headers `Name:Value` | Arbitrary HTTP header, e.g. `X-API-Token:123` |
| URL parameters `name==value` | Appends the given name/value pair as a querystring parameter to the URL. The `==` separator is used. |
| Data Fields `field=value`, `field=@file.txt` | Request data fields to be serialized as a JSON object (default), to be form-encoded (with `--form, -f`), or to be serialized as `multipart/form-data` (with `--multipart`) |
| Raw JSON fields `field:=json` | Useful when sending JSON and one or more fields need to be a `Boolean`, `Number`, nested `Object`, 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.png`, or `'cv@cv.txt;type=text/markdown'`. With `--form`, the presence of a file field results in a `--multipart` request |
Note that the structured data fields aren’t the only way to specify request data:
@@ -411,10 +417,10 @@ Host: pie.dev
### Explicit JSON
You can use `--json, -j` to explicitly set `Accept` to `application/json` regardless of whether you are sending data (it’s a shortcut for setting the header via the usual header notation: `http url Accept:'application/json, */*;q=0.5'`).
You can use `--json, -j` to explicitly set `Accept` to `application/json` regardless of whether you are sending data (it’s a shortcut for setting the header via the usual header notation: `http url Accept:'application/json, */*;q=0.5'`).
Additionally, HTTPie will try to detect JSON responses even when the `Content-Type` is incorrectly `text/plain` or unknown.
### Non-string JSON fields
### Non-string JSON fields
Non-string JSON fields use the `:=` separator, which allows you to embed arbitrary JSON data into the resulting JSON object.
Additionally, text and raw JSON files can also be embedded into fields using `=@` and `:=@`:
@@ -717,9 +723,9 @@ the [sessions](#sessions) feature.
$ http -a username pie.dev/basic-auth/username/password
```
### Empty password
### Empty password
```bash
```bash
$ http -a username: pie.dev/headers
```
@@ -927,13 +933,13 @@ By default, HTTPie only outputs the final response and the whole response
Print request and response headers:
```bash
$ http --print=Hh PUT pie.dev/put hello=world
$ http --print=Hh PUT pie.dev/put hello=world
```
### Verbose output
### Verbose output
`--verbose` can often be useful for debugging the request and generating documentation examples:
`--verbose` can often be useful for debugging the request and generating documentation examples:
```bash
$ http --verbose PUT pie.dev/put hello=world
PUT /put HTTP/1.1
@@ -942,10 +948,10 @@ It accepts a string of characters each of which represents a specific part of th
Content-Type: application/json
Host: pie.dev
User-Agent: HTTPie/0.2.7dev
{
"hello": "world"
}
{
"hello": "world"
}
HTTP/1.1 200 OK
Connection: keep-alive
@@ -1162,13 +1168,13 @@ Syntax highlighting is applied to HTTP headers and bodies (where it makes sense)
| `--pretty=format` | Apply formatting |
| `--pretty=none` | Disables output processing. Default for redirected output |
You can further control the applied formatting via the more granular [format options](#format-options).
You can further control the applied formatting via the more granular [format options](#format-options).
### Format options
### Format options
The `--format-options=opt1:value,opt2:value` option allows you to control how the 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 |
| ---------------: | :-----------: | ------------------------ |
| `headers.sort` | `true` | `--sorted`, `--unsorted` |
@@ -1178,12 +1184,12 @@ Also, the following formatting is applied:
| `xml.format` | `true` | 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:
```bash
$ http --format-options headers.sort:false,json.sort_keys:false,json.indent:2 pie.dev/get
```
```
There are also two shortcuts that allow you to quickly disable and re-enable
sorting-related format options (currently it means JSON keys and headers):
@@ -1192,14 +1198,14 @@ You can further control the applied formatting via the more granular [format opt
This is something you will typically store as one of the default options in your [config](#config) file.
### Binary data
Binary data is suppressed for terminal output, which makes it safe to perform requests to URLs that send back binary data.
Binary data is also suppressed in redirected but prettified output.
The connection is closed as soon as we know that the response body is binary,
```bash
$ http pie.dev/bytes/2000
```
Binary data is also suppressed in redirected but prettified output.
The connection is closed as soon as we know that the response body is binary,
```bash
$ http pie.dev/bytes/2000
```
You will nearly instantly see something like this: