Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] http.ClientOptions.maxRedirections not working #4795

Closed
KaKi87 opened this issue Jul 29, 2022 · 1 comment
Closed

[bug] http.ClientOptions.maxRedirections not working #4795

KaKi87 opened this issue Jul 29, 2022 · 1 comment
Labels
status: in progress Implementation is proceeding smoothly type: bug

Comments

@KaKi87
Copy link

KaKi87 commented Jul 29, 2022

Describe the bug

http.ClientOptions.maxRedirections provides undesired outcomes when trying to prevent redirects :

http.ClientOptions.maxRedirections Cargo.toml > tauri > features Outcome
0 ["api-all"] Redirected
1 ^ Redirected
0 ["api-all", "reqwest-client"] Redirected
1 ^ Network Error: error following redirect for url (https://d.cv.vg/8Qa): too many redirects

This most likely occurs when trying to limit redirects to a specific amount as well.

Reproduction

Call http.getClient with the specified Cargo.toml configuration and maxRedirections option value.

Expected behavior

The request is not redirected and succeeds, like the following Node equivalent :

import axios from 'axios';
(async () => {
    const {
        status,
        headers: {
            location
        },
        data
    } = await axios(
        'https://d.cv.vg/8Qa',
        {
            maxRedirects: 0,
            validateStatus: status => status === 302
        }
    );
    console.log(JSON.stringify(
        {
            status,
            location,
            data
        },
        null,
        4
    ));
})().catch(console.error);

Which outputs :

{
    "status": 302,
    "location": "https://source.unsplash.com/1080x2248/?technology",
    "data": {
        "url": "https://source.unsplash.com/1080x2248/?technology",
        "randomConfigIndex": 4,
        "creationTimestamp": 1645028091549,
        "config": {
            "configs": [
                {
                    "url": "https://source.unsplash.com/1080x2248/?nature"
                },
                {
                    "url": "https://source.unsplash.com/1080x2248/?space"
                },
                {
                    "url": "https://source.unsplash.com/1080x2248/?food"
                },
                {
                    "url": "https://source.unsplash.com/1080x2248/?animals"
                },
                {
                    "url": "https://source.unsplash.com/1080x2248/?technology"
                }
            ],
            "isRandom": true
        }
    }
}

Platform and versions

Environment
  › OS: Ubuntu 21.10 X64
  › Node.js: 16.16.0
  › npm: 8.11.0
  › pnpm: Not installed!
  › yarn: 1.22.19
  › rustup: 1.24.3
  › rustc: 1.61.0
  › cargo: 1.61.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.0.2
  › @tauri-apps/api [NPM]: 1.0.1
  › tauri [RUST]: 1.0.2,
  › tauri-build [RUST]: 1.0.2,
  › tao [RUST]: 0.12.1,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  › distDir: ../dist
  › devPath: http://localhost:1234/

App directory structure
  ├─ src
  ├─ .git
  ├─ .parcel-cache
  ├─ src-tauri
  ├─ .idea
  ├─ dist
  └─ node_modules

Stack trace

No response

Additional context

No response

@KaKi87 KaKi87 added status: needs triage This issue needs to triage, applied to new issues type: bug labels Jul 29, 2022
@lucasfernog lucasfernog added status: in progress Implementation is proceeding smoothly and removed status: needs triage This issue needs to triage, applied to new issues labels Jul 31, 2022
@lucasfernog
Copy link
Member

Thanks for catching this, fix will be available in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in progress Implementation is proceeding smoothly type: bug
Projects
None yet
Development

No branches or pull requests

2 participants