You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-Drop support for Python 3.6. ([#1177](https://github.com/httpie/httpie/issues/1177))
8
+
-Dropped support for Python 3.6. ([#1177](https://github.com/httpie/httpie/issues/1177))
9
9
- Improved startup time by 40%. ([#1211](https://github.com/httpie/httpie/pull/1211))
10
10
- Added support for nested JSON syntax. ([#1169](https://github.com/httpie/httpie/issues/1169))
11
11
- Added `httpie plugins` interface for plugin management. ([#566](https://github.com/httpie/httpie/issues/566))
@@ -15,12 +15,12 @@ This project adheres to [Semantic Versioning](https://semver.org/).
15
15
- Added support for _receiving_ multiple HTTP headers lines with the same name. ([#1207](https://github.com/httpie/httpie/issues/1207))
16
16
- Added support for basic JSON types on `--form`/`--multipart` when using JSON only operators (`:=`/`:=@`). ([#1212](https://github.com/httpie/httpie/issues/1212))
17
17
- Added support for automatically enabling `--stream` when `Content-Type` is `text/event-stream`. ([#376](https://github.com/httpie/httpie/issues/376))
18
-
- Added support for displaying the total elapsed time throguh`--meta`/`-vv` or `--print=m`. ([#243](https://github.com/httpie/httpie/issues/243))
18
+
- Added support for displaying the total elapsed time through`--meta`/`-vv` or `--print=m`. ([#243](https://github.com/httpie/httpie/issues/243))
19
19
- Added new `pie-dark`/`pie-light` (and `pie`) styles that match with [HTTPie for Web and Desktop](https://httpie.io/product). ([#1237](https://github.com/httpie/httpie/issues/1237))
20
20
- Added support for better error handling on DNS failures. ([#1248](https://github.com/httpie/httpie/issues/1248))
21
21
- Added support for storing prompted passwords in the local sessions. ([#1098](https://github.com/httpie/httpie/issues/1098))
22
22
- Added warnings about the `--ignore-stdin`, when there is no incoming data from stdin. ([#1255](https://github.com/httpie/httpie/issues/1255))
23
-
-Broken plugins will no longer crash the whole application. ([#1204](https://github.com/httpie/httpie/issues/1204))
23
+
-Fixed crashing due to broken plugins. ([#1204](https://github.com/httpie/httpie/issues/1204))
24
24
- Fixed auto addition of XML declaration to every formatted XML response. ([#1156](https://github.com/httpie/httpie/issues/1156))
25
25
- Fixed highlighting when `Content-Type` specifies `charset`. ([#1242](https://github.com/httpie/httpie/issues/1242))
26
26
- Fixed an unexpected crash when `--raw` is used with `--chunked`. ([#1253](https://github.com/httpie/httpie/issues/1253))
JSON is the *lingua franca* of modern web services and it is also the **implicit content type** HTTPie uses by default.
601
+
JSON is the *lingua franca* of modern web services, and it is also the **implicit content type** HTTPie uses by default.
602
602
603
603
Simple example:
604
604
@@ -624,7 +624,7 @@ Host: pie.dev
624
624
If your command includes some data [request items](#request-items), they are serialized as a JSON object by default. HTTPie also automatically sets the following headers, both of which can be overwritten:
@@ -677,132 +677,106 @@ The `:=`/`:=@` syntax is JSON-specific. You can switch your request to `--form`
677
677
and string, float, and number values will continue to be serialized (as string form values).
678
678
Other JSON types, however, are not allowed with `--form` or `--multipart`.
679
679
680
-
### Nested JSON fields
680
+
### Nested JSON
681
681
682
-
In the past (pre-3.0), HTTPie's data operators (`=`/`:=`) allowed you to
683
-
directly create basic JSON objects right from your terminal. Though this
684
-
functionality was limited to only top-level keys.
685
-
686
-
```bash
687
-
$ http --offline --print=B pie.dev/post \
688
-
type=success
689
-
```
690
-
691
-
```json
692
-
{
693
-
"type": "success"
694
-
}
695
-
```
696
-
697
-
For embedding more complex JSON objects, you needed to use the `:=` operator.
698
-
699
-
```bash
700
-
$ http --offline --print=B pie.dev/post \
701
-
type=success \
702
-
'product:={"name":"something", "price":10}'
703
-
```
704
-
705
-
```json
706
-
{
707
-
"product": {
708
-
"name": "something",
709
-
"price": 10
710
-
},
711
-
"type": "success"
712
-
}
713
-
```
714
-
715
-
Starting with 3.0, we have created a mini language in HTTPie's own syntax to
716
-
build complex JSON objects with ease. This syntax was inspired by the [JSON form](https://www.w3.org/TR/html-json-forms/)
717
-
proposal for HTML, though we have changed a lot of parts to offer the best experience.
682
+
If your use case involves sending complex JSON objects as part of the request body,
683
+
HTTPie can help you build them right from your terminal. You still use the existing
684
+
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.
718
685
719
686
#### Introduction
720
687
721
-
Let's start with a simple introduction, and build the JSON object we have seen in the example
722
-
above:
688
+
Let's start with a simple example, and build a simple search query:
723
689
724
690
```bash
725
691
$ http --offline --print=B pie.dev/post \
726
-
type=success \
727
-
product[name]=something \
728
-
product[price]:=10
692
+
category=tools \
693
+
search[type]=id \
694
+
search[id]:=1
729
695
```
730
696
731
-
With the new syntax, you can designate the path for the value. For example `product[name]` means
732
-
create a new object under the `product` key, and set the `name` field of that object to the given
733
-
value.
697
+
In the example above, the `search[type]` is an instruction for creating an object called `search`, and setting the `type` field of it to the given value (`"id"`).
698
+
699
+
Also note that, just as the regular syntax, you can use the `:=` operator to directly pass raw JSON values (e.g numbers in the case above).
734
700
735
701
```json
736
702
{
737
-
"product": {
738
-
"name": "something",
739
-
"price": 10
740
-
},
741
-
"type": "success"
703
+
"category": "tools",
704
+
"search": {
705
+
"id": 1,
706
+
"type": "id"
707
+
}
742
708
}
743
709
```
744
710
745
-
You can also build arrays, through `[]` suffix. Which means create a list, and append the value
746
-
to that list:
711
+
Building arrays is also possible, through `[]` suffix (an append operation). This tells HTTPie to create an array in the given path (if there is not one already), and append the given value to that array.
747
712
748
713
```bash
749
714
$ http --offline --print=B pie.dev/post \
750
-
search[keywords][]=soda \
751
-
search[keywords][]=fries
715
+
category=tools \
716
+
search[type]=keyword \
717
+
search[keywords][]=APIs \
718
+
search[keywords][]=CLI
752
719
```
753
720
754
721
```json
755
722
{
723
+
"category": "tools",
756
724
"search": {
757
725
"keywords": [
758
-
"soda",
759
-
"fries"
760
-
]
726
+
"APIs",
727
+
"CLI"
728
+
],
729
+
"type": "keyword"
761
730
}
762
731
}
763
732
```
764
733
765
-
If you want to specify the direct index, that is also supported:
734
+
If you want to explicitly specify the position of elements inside an array,
735
+
you can simply pass the desired index as the path:
766
736
767
737
```bash
768
738
$ http --offline --print=B pie.dev/post \
769
-
search[keywords][0]=soda \
770
-
search[keywords][1]=fries
739
+
category=tools \
740
+
search[type]=keyword \
741
+
search[keywords][1]=APIs \
742
+
search[keywords][2]=CLI
771
743
```
772
744
773
745
```json
774
746
{
747
+
"category": "tools",
775
748
"search": {
776
749
"keywords": [
777
-
"soda",
778
-
"fries"
779
-
]
750
+
"CLIs",
751
+
"API"
752
+
],
753
+
"type": "keyword"
780
754
}
781
755
}
782
756
```
783
757
784
-
You can also create 'sparse arrays' (arrays where you set 2 non-consecutive indexes), which
785
-
the missing values gets nullified:
758
+
If there are any missing indexes, HTTPie will nullify them in order to create a concrete object that can be sent:
786
759
787
760
```bash
788
761
$ http --offline --print=B pie.dev/post \
789
-
search[keywords][2]=soda \
790
-
search[keywords][5]=fries \
791
-
search[keywords][]=fish
762
+
category=tools \
763
+
search[type]=platforms \
764
+
search[platforms][]=Terminal \
765
+
search[platforms][1]=Desktop \
766
+
search[platforms][3]=Mobile
792
767
```
793
768
794
769
```json
795
770
{
771
+
"category": "tools",
796
772
"search": {
797
-
"keywords": [
798
-
null,
799
-
null,
800
-
"soda",
773
+
"platforms": [
774
+
"Terminal",
775
+
"Desktop",
801
776
null,
802
-
null,
803
-
"fries",
804
-
"fish"
805
-
]
777
+
"Mobile"
778
+
],
779
+
"type": "platforms"
806
780
}
807
781
}
808
782
```
@@ -811,27 +785,29 @@ It is also possible to embed raw JSON to a nested structure, for example:
811
785
812
786
```bash
813
787
$ http --offline --print=B pie.dev/post \
814
-
invitation[type]=meetup \
815
-
'invitation[dates]:=[2021, 2022, 2023, 2024]' \
816
-
invitation[dates][]:=2025
788
+
category=tools \
789
+
search[type]=platforms \
790
+
'search[platforms]:=["Terminal", "Desktop"]' \
791
+
search[platforms][]=Web \
792
+
search[platforms][]=Mobile
817
793
```
818
794
819
795
```json
820
796
{
821
-
"invitation": {
822
-
"dates": [
823
-
2021,
824
-
2022,
825
-
2023,
826
-
2024,
827
-
2025
797
+
"category": "tools",
798
+
"search": {
799
+
"platforms": [
800
+
"Terminal",
801
+
"Desktop",
802
+
"Web",
803
+
"Mobile"
828
804
],
829
-
"type": "meetup"
805
+
"type": "platforms"
830
806
}
831
807
}
832
808
```
833
809
834
-
And for the last, let's create a very deeply nested JSON object:
810
+
And just to demonstrate all of these features together, let's create a very deeply nested JSON object:
Please note that on some very complex JSON structures, manually building the JSON object right from the terminal
963
-
might be more complicated compared to typing it on a file and directly sending it through HTTPie. Depending on your
964
-
use case, some of the following examples can help:
938
+
For very complex JSON structures, it may be more convenient to [pass it as raw request body](#raw-request-body), for example:
965
939
966
940
```bash
967
941
$ echo -n '{"hello": "world"}'| http POST pie.dev/post
968
942
```
969
943
970
-
```bash
971
-
$ http --raw '{"hello": "world"}' POST pie.dev/post
972
-
```
973
-
974
944
```bash
975
945
$ http POST pie.dev/post < files/data.json
976
946
```
@@ -1253,7 +1223,7 @@ the [sessions](#sessions) feature.
1253
1223
The currently supported authentication schemes are Basic and Digest (see [auth plugins](#auth-plugins) for more). There are two flags that control authentication:
| `--auth, -a` | Pass either a `username:password` pair or a `token` as the argument. If the selected authenticated method requires username/password combination and if you only specify a username (`-a username`), you’ll be prompted for the password before the request is sent. To send an empty password, pass `username:`. The `username:password@hostname` URL syntax is supported as well (but credentials passed via `-a` have higher priority) |
1258
1228
| `--auth-type, -A` | Specify the auth mechanism. Possible values are `basic`, `digest`, `bearer` or the name of any [auth plugins](#auth-plugins) you have installed. The default value is `basic` so it can often be omitted |
1259
1229
@@ -1592,7 +1562,7 @@ The response headers are downloaded always, even if they are not part of the out
1592
1562
In addition to crafting structured [JSON](#json) and [forms](#forms) requests with the [request items](#request-items) syntax, you can provide a raw request body that will be sent without further processing.
1593
1563
These two approaches for specifying request data (i.e., structured and raw) cannot be combined.
1594
1564
1595
-
There’re three methods for passing raw request data: piping via `stdin`,
1565
+
There are three methods for passing raw request data: piping via `stdin`,
0 commit comments