wymsee / cordova-HTTP

Cordova / Phonegap plugin for communicating with HTTP servers. Allows for SSL pinning!
MIT License
372 stars 301 forks source link

Spoofing request headers and cookies? #68

Open Zerokami opened 8 years ago

Zerokami commented 8 years ago

I want to do some webscraping and was wondering if it was possible to set the "referrer" header and other headers to whatever I want. Also can I add custom cookies and bypass the default cookies?

Jacse commented 8 years ago

+1 would really like to have cookie-support as well

Jacse commented 8 years ago

Nevermind, the plugin was already capable of doing what I needed. @Logmytech is set the Cookie-header like so:

cordovaHTTP.setHeader("Cookie", "cookie1=cookie_value1 ; another_cookie=cookie_value2"), function() {
    console.log('session cookie success!');
}, function() {
     console.log('session cookie error :(');
});
ehaab commented 7 years ago

@Jacse if we want to make post request with headers ,should we add your line of code before post request or we can add the headers inside post request?

Jacse commented 7 years ago

@ehaab before the request if I remmenes correctly. Also no callbacks needed

ehaab commented 7 years ago

@Jacse could you tell how to construct the post request if i want to send these values to api ? I don't know which ones should be as header and which ones as data !

POST http://xxxxxxxxxxxxxxx/api/itemURL/1234 HTTP/1.1
API_KEY: XXXXXXXXXXXXXXXXXXXXXXXX
UserID: XXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.2.2; Galaxy Nexus Build/JDQ39)
Host: XXXXXXXXXXXXXXXXXXXXX
Cookie: __cfduid=2342435465423eafrsdfdfaesdfasdqwr41234
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Type: application/x-www-form-urlencoded
Content-Length: 0