3

I am trying to create a GET request using HttpRequester ( addon in firefox ). And I am analyzing packet using the Http Fox ( addon in firefox ). I have created a GET packet with following parameters
url :-http://enquiry.indianrail.gov.in/ntes
Headers
Host :- enquiry.indianrail.gov.in
Referer :- http://enquiry.indianrail.gov.in/ntes/

When I submit this request. I get a response code of 200. In the HttpFox add on, When I analyze my packet, I see that there is additional field in header named
cookie with value _ga=GA1.3.150104442.1441509203.
Relevant Information
Before sending the request deleted all the cookies for enquiry.indianrail.gov.in .
Running all this behind a proxy server.
I get the respone 200 in HttpRequester, while 302 in HttpFox
I want to know, If I am not attaching cookie in my header,than Why HttpFox shows cookie in the header ( with response code 302 ) ?

rbansal
  • 1,184
  • 14
  • 21
  • I am working with same one can you check this code here - https://github.com/ramnew2006/quickpnr/blob/master/temp.php – Olivia Nielsen Sep 07 '15 at 15:22
  • @OliviaNielsen there are more headers in the request packet jsesssionid etc – rbansal Sep 07 '15 at 17:10
  • @OliviaNielsen are you also experiencing the same problem ?? – rbansal Sep 07 '15 at 17:11
  • @OliviaNielsen I also tried sending the packet from hurl.it , but the request fails because it take too long time – rbansal Sep 07 '15 at 17:19
  • I don't know how to use that code can you check that form github? – Olivia Nielsen Sep 07 '15 at 17:41
  • If your question is why are you getting 302 response, there could be many reasons. It is probably not related to the _ga cookie. Please show us all the request headers, when not using httprequester, and then again when using httprequester. – glenschler Sep 08 '15 at 10:52
  • Are you making the request with same captchaId cookie every time? The server will not accept a previously recorded captchaId. – glenschler Sep 08 '15 at 11:50

1 Answers1

2

The _ga cookie is a google tracking cookie. It is a client cookie created by google analytics.js running in your browser. The analytics.js is included by common.js, which is included in the /ntes home page.

HttpRequester will not execute the javascript logic which creates the client side _ga cookie. It may not automatically load the analytics.js either. If you are trying to automate a page that needs to execute javascript, one simple way is to use a headless browser, such as phantomjs

glenschler
  • 178
  • 3
  • 9
  • When I create a new packet, How does analytics.js know that a cookie need to be inserted in the request for a site that is yet to be visited. – rbansal Sep 08 '15 at 04:14
  • httprequester will not create client side cookie, but even than the cookie is being made – rbansal Sep 08 '15 at 04:52
  • Httprequester will play back recorded client side generated cookies, if the initial response header does not set the cookie to something new – glenschler Sep 08 '15 at 11:52
  • but the very first packet should not contain any cookie, only after a response, the cookie is stored at client side. so Why does the very first Http request when analyzed by HttpFox shows the google analytics cookie, even though I didn't added it in the request, I created using HttpRequester. – rbansal Sep 08 '15 at 16:36
  • Just use the [developer tools](https://www.mozilla.org/en-US/firefox/developer/) that are built into firefox by default. You will see all the network requests which are made (You are not using the word packet correctly. You mean to say HTTP request). After the 1st request is made, the analytics.js javascript is executed, and it creates the _ga cookie on the client side; it is not a server side cookie that you seem to understand. Search that javascript and you will see the "_ga" in the code. [javascript creates the cookie](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie) – glenschler Sep 08 '15 at 16:56
  • I do not use HttpRequester. Other similar record & playback tools, will record the _ga cookie. Since it was not sent by the server, and since the tool does not execute javascript, it defaults to playback with the recorded cookie. You can prove that if compare your recording against the playback. You should ask a new question, asking how to turn this default playback in Httprequester mode off. – glenschler Sep 08 '15 at 17:16
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89092/discussion-between-glenschler-and-rax). – glenschler Sep 08 '15 at 17:22
  • let me write, What I understood and you just tell me, Where I am getting wrong. First of all HTTP request will be made to the webpage, than the page will be send as response and analytics.js will be downloaded, Now before sending the another HTTP request, analytics.js will be executed and _ga cookie will be added. Please tell me, whether I a wrong or right ? – rbansal Sep 08 '15 at 17:25