http-rs / http-rs/surf

Surf get and post requests do not work

Open
#72 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.5k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

When I tried surf for make get request on `https://static.crates.io/crates/{crate}/{crate}-{version}.crate` for example I get CloudFront responding 501 Not Yet Implemented, "The request could not be satisfied". Cloudfront is not the only website that do not like surf's get requests.

I also tried to make surf post requests, those only worked with the `curl-client` as the `hyper-client` do not send the body to the server. There is already an open issue about this #46.

So I end up doing crazy things that worked, I declared two dependencies of the same package and use the one with curl for the post and the one with hyper for the get requests.

```toml
[dependencies.surf]
git = "https://github.com/badboy/surf.git"
branch = "hyper-client"
default-features = false
features = ["hyper-client"]

[dependencies.surf-curl]
package = "surf"
git = "https://github.com/rustasync/surf.git"
branch = "master"
```

Get and Post raw requests

#### Get requests with the curl feature (does not work)

A typical get request with surf:
```
GET /crates/pcsc/pcsc-2.2.0.crate HTTP/1.1
Host: 127.0.0.1:8000
Accept: */*
Accept-Encoding: deflate, gzip
user-agent: curl/7.54.0 isahc/0.7.3
transfer-encoding: chunked
Expect: 100-continue

0

```

And here is one working with the curl command line:

```
GET /crates/pcsc/pcsc-2.2.0.crate HTTP/1.1 HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: curl/7.54.0
Accept: */*

```

#### Post requests with the hyper feature (does not work)

Here is one post request with surf:
```
POST /indexes/bf16b15f/documents HTTP/1.1
x-meili-api-key: ckxGd3f97DXVKAhfkZ2mBTSc
content-type: application/json
host: 127.0.0.1:8000
transfer-encoding: chunked

0

```

And here is one using the curl command:
```
POST /indexes/bf16b15f/documents HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: curl/7.54.0
Accept: */*
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

"Hello"
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.