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

Faraday request returns 403 while equivalent curl request returns 200 #1608

Open
michelson opened this issue Dec 19, 2024 · 0 comments
Open

Comments

@michelson
Copy link

michelson commented Dec 19, 2024

Basic Info

  • Faraday Version: 3.3.5
  • Ruby Version: faraday-2.12.2

You can create an issue on the Faraday GitHub repository by following these steps:

  1. Go to the GitHub issue page for Faraday: [Create new issue on Faraday](https://github.com/lostisland/faraday/issues/new/choose)
  2. Select the "Bug report" template.
  3. Fill in the following details:

Title:

Faraday request returns 403 while equivalent curl request returns 200

Description:

### Issue
When making a request using Faraday with the following Ruby code:

```ruby
response = Faraday.get('https://circle.so') do |req|
  req.headers['accept-encoding'] = "gzip"
  req.headers['accept-language'] = 'en-US,en;q=0.9,es-US;q=0.8,es;q=0.7,la;q=0.6'
  req.headers['cache-control'] = 'max-age=0'
  req.headers['priority'] = 'u=0, i'
  req.headers['sec-ch-ua'] = '"Google Chrome";v="131", "Chromium";v="131", "Not_A Brand";v="24"'
  req.headers['sec-ch-ua-mobile'] = '?0'
  req.headers['sec-ch-ua-platform'] = '"macOS"'
  req.headers['sec-fetch-dest'] = 'document'
  req.headers['sec-fetch-mode'] = 'navigate'
  req.headers['sec-fetch-site'] = 'same-origin'
  req.headers['sec-fetch-user'] = '?1'
  req.headers['upgrade-insecure-requests'] = '1'
  req.headers['user-agent'] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
end

The response consistently returns 403 Forbidden, while using an equivalent curl command, it returns 200 OK.

Equivalent curl command:

curl -X GET "https://circle.so/" \\
  -H "accept-language: en-US,en;q=0.9,es-US;q=0.8,es;q=0.7,la;q=0.6" \\
  -H "cache-control: max-age=0" \\
  -H "priority: u=0, i" \\
  -H "sec-ch-ua: \"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"" \\
  -H "sec-ch-ua-mobile: ?0" \\
  -H "sec-ch-ua-platform: \"macOS\"" \\
  -H "sec-fetch-dest: document" \\
  -H "sec-fetch-mode: navigate" \\
  -H "sec-fetch-site: same-origin" \\
  -H "sec-fetch-user: ?1" \\
  -H "upgrade-insecure-requests: 1" \\
  -H "user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"

Expected behavior

Both the curl command and the Faraday request should return 200 OK.

Actual behavior

  • Faraday response: 403 Forbidden
  • Curl response: 200 OK
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

No branches or pull requests

1 participant