Skip to content

Commit a3b4d93

Browse files
committed
server: use proper Content-Type in curl examples
Without the header Content-Type: application/json, curl will POST with Content-Type: application/x-www-form-urlencoded Though our simple server doesn't care, the httplib.h used has a limit with CPPHTTPLIB_FORM_URL_ENCODED_PAYLOAD_MAX_LENGTH 8192 With Content-Type: application/json, we can send large json data.
1 parent a728a0d commit a3b4d93

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

examples/server/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Using [curl](https://curl.se/). On Windows `curl.exe` should be available in the
6666
```sh
6767
curl --request POST \
6868
--url http://localhost:8080/completion \
69+
--header "Content-Type: application/json" \
6970
--data '{"prompt": "Building a website can be done in 10 simple steps:","n_predict": 128}'
7071
```
7172

examples/server/chat.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ tokenize() {
3232
--silent \
3333
--request POST \
3434
--url "${API_URL}/tokenize" \
35+
--header "Content-Type: application/json" \
3536
--data-raw "$(jq -ns --arg content "$1" '{content:$content}')" \
3637
| jq '.tokens[]'
3738
}
@@ -64,6 +65,7 @@ chat_completion() {
6465
--no-buffer \
6566
--request POST \
6667
--url "${API_URL}/completion" \
68+
--header "Content-Type: application/json" \
6769
--data-raw "${DATA}")
6870

6971
printf "\n"

0 commit comments

Comments
 (0)