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

[http] Incorrect headers order #1882

Closed
vitalygashkov opened this issue Oct 4, 2024 · 0 comments · Fixed by #1884
Closed

[http] Incorrect headers order #1882

vitalygashkov opened this issue Oct 4, 2024 · 0 comments · Fixed by #1884

Comments

@vitalygashkov
Copy link

Some servers pay attention to the order of the HTTP request headers. But it seems that this plugin automatically sorts headers in alphabetical order, which provokes a server error.

Here is an example of a successful request execution on Node.js:

(async () => {
  const response = await fetch(
    'https://ctx.playfamily.ru/screenapi/v1/uiscreeninfo/web/1?sid=u_SlptSXyHa2aGC8YwEhGqkmftfNGt6c3bAR5Y9piFt7nQMGuXbwFOGtOzX6kiwg_NNbB7d93IruwzzIX8-oeWxurzZ_18S_JCJ9RbypGxk&activeMultiProfileId=00000000-121d-cbef-0000-000000000000&clientSessionId=19252dea-e601-7aaa-9838-dded10cc329c&clientTraceId=19252deb-4e12-7901-bab3-f0ae5a8bbf10',
    {
      headers: {
        'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Google Chrome";v="128"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"macOS"',
        'upgrade-insecure-requests': '1',
        'user-agent':
          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36',
        accept:
          'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
        'sec-fetch-site': 'same-site',
        'sec-fetch-mode': 'navigate',
        'sec-fetch-user': '?1',
        'sec-fetch-dest': 'document',
        'accept-encoding': 'gzip, deflate, br, zstd',
        'accept-language': 'en-US',
        'x-scrapi-client-ts': '1727967180000',
        'x-scrapi-signature': '983648b920bc2ffc008b67936deae1da',
      },
    }
  );
  const json = await response.json();
  console.log(json);

  // {
  //   status: 0,
  //   authorized: true,
  //   userInfo: {
  //     id: '303942639',
  //     ...
})();

At the time of Issue creation, the link is working; if it suddenly stops, I can provide a new one for testing and debugging.

If you execute the exact same request using fetch from the Tauri's http plugin, you get an error:

import { fetch } from '@tauri-apps/plugin-http';

(async () => {
  // const response = await fetch(
  // ...
  // const json = await response.json();
  // console.log(json);

  // {
  //   antibot: true,
  //   ...
  // }
})();

Also, in order to send all headers completely, you need to enable the "unsafe-headers" plugin option on the Rust code side.

I'm using the v2 version of the plugin, but I assume this applies to all versions, though I haven't tested it on others.

amrbashir added a commit that referenced this issue Oct 4, 2024
lucasfernog added a commit that referenced this issue Oct 9, 2024
* fix(http): retain headers order

closes #1882

* simplify if

* actually set headers

---------

Co-authored-by: Lucas Nogueira <[email protected]>
Sir-Thom pushed a commit to Sir-Thom/plugins-workspace that referenced this issue Oct 22, 2024
* fix(http): retain headers order

closes tauri-apps#1882

* simplify if

* actually set headers

---------

Co-authored-by: Lucas Nogueira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant