Alex
Alex

Reputation: 7521

How to change an HTTP request to imitate sending from US?

I am repeating the airbnb request by Java applicaiton using Apache HTTP Components while being outside of the US. In Chrome and Mozilla I am getting the price in dollars, in my Java application in the local currency. Also, I am getting the local currency price in Safari that was not used for airbnb before. So, the difference is in cookies, correct?

However, when I see the cookies in Chrome I do not see the cookie that is responsible for location. There is a list of 45 cookies, should I add to HTTP request all of them? Is there any other way to get prices in dollars?

There is no currency in this list of 45 cookies, still I tried to add the currency

      BasicCookieStore cookieStore = new BasicCookieStore();
      BasicClientCookie cookie = new BasicClientCookie("currency", "USD");
      cookie.setDomain(".airbnb.com");
      cookie.setPath("/");
      cookieStore.addCookie(cookie);

      HttpClient client = HttpClientBuilder.create().setDefaultCookieStore(cookieStore).build();

This did not help. Would it be possible to add cookies from the Chrome cookies directory?

Upvotes: 0

Views: 144

Answers (2)

Koby Douek
Koby Douek

Reputation: 16693

Usually, the browser's language appears as accept-language in HTTP request headers. For my knowledge, there are no cookies indicating the origin country of the request or the currency in all browsers and in all HTTP request (I think Chrome has one, but it's unreliable).

If this header key is not there, alternatively, you can check http-accept-language in the request header (it depends on the parser you are using).

enter image description here

Upvotes: 0

Erdem E.
Erdem E.

Reputation: 170

You are right, it is Cookies. You are wrong it's not location. There is a currency header as can be seen: enter image description here

This is also how it is set during a GET method:

enter image description here

Upvotes: 1

Related Questions