lwthiker / curl-impersonate

curl-impersonate: A special build of curl that can impersonate Chrome & Firefox
MIT License
3.45k stars 229 forks source link

POST succeeds, but GET failed #136

Open cynosureabu opened 1 year ago

cynosureabu commented 1 year ago

I encountered a weird issue when calling curl impersonate against a website.

The POST request works just fine and return result successfully.

However, GET request returns Unauthorized error from the server, which seems like cookie was not passed over. Does anyone encounter this before? All cookie values are correct as they all succeed with POST.

A-Posthuman commented 1 year ago

One random thing you could check is how you're positioning the cookie in your header order. I've found that if you use curl's default cookie handling it tends to insert the cookie earlier in the header order than the real Chrome does. I believe the real Chrome puts the cookie at the end of all the other headers.

It's possible but probably unlikely that the site you're using might be checking for that. In my case I had to use my own cookie handling code and manually put the cookie header into the right spot.

Also a suggestion I guess to the curl-impersonate project would be to add cookie header positioning as a further feature to think about incorporating?