Bug #2618

Cookie set in plugin.addHTTPAuth->setHeader in is overriden by Cookie from .hts/showtime/settings/httpcookies

Added by Leonid Protasov over 5 years ago. Updated over 5 years ago.

Status:FixedStart date:05/16/2015
Priority:HighDue date:
Assignee:Andreas Smas% Done:

100%

Category:General
Target version:4.10
Found in version:4.9.434 Platform:Linux

Description

My code is;

        id = '1234567';
        plugin.addHTTPAuth('.*yoooo\\.tv', function(req) {
            req.setHeader('Cookie', 'yoooo=' + id);
        });
        plugin.addHTTPAuth('.*yoooo\\.tv.*', function(req) {
            req.setHeader('Cookie', 'yoooo=' + id);
        });
        var doc = showtime.httpReq('http://yoooo.tv/json/channel_now');

httpcookies file contains:
    {
        "name": "yoooo",
        "path": "/",
        "domain": "yoooo.tv",
        "value": "E4663CDA465AEE1D0642E461A95799BA",
        "expire": 1434331486
    },               

Movian won't set Cookie value from SetHeader:
HTTP            [DEBUG]: Connected to yoooo.tv:80 (cid=2)
HTTP-2          [DEBUG]: Sending request for http://yoooo.tv/json/channel_now (cid=2)
HTTP-2          [DEBUG]: > GET /json/channel_now HTTP/1.1
HTTP-2          [DEBUG]: > Cookie: yoooo=E4663CDA465AEE1D0642E461A95799BA
HTTP-2          [DEBUG]: > User-Agent: Movian Linux/x86_64 4.9.434.g1b404
HTTP-2          [DEBUG]: > Connection: keep-alive
HTTP-2          [DEBUG]: > Accept: */*
HTTP-2          [DEBUG]: > Accept-Encoding: identity
HTTP-2          [DEBUG]: > Host: yoooo.tv

But if I manually delete that cookie from .hts/showtime/settings/httpcookies it is setting correctly.

I suppose setHeader should override the Cookie in .hts/showtime/settings/httpcookies. Moreover it'd be good that we can overwrite/delete and get the Cookie in httpcookies from plugin...

Associated revisions

Revision b7be5b0f
Added by Andreas Smas over 5 years ago

httpclient: Make it possible to override and clear cookies using HTTP inspector callbacks

Fixes #2618

Change included in version 4.9.441

History

#1 Updated by Andreas Smas over 5 years ago

I just saw there is a setCookie function in the http request object.

So try

req.setCookie('yoooo', '');

#2 Updated by Andreas Smas over 5 years ago

But it seems it can't override cookies... I'll fix that

#3 Updated by Andreas Smas over 5 years ago

  • Status changed from New to Fixed
  • % Done changed from 0 to 100

#4 Updated by Andreas Smas over 5 years ago

Example:

var http = require('showtime/http');
var io = require('native/io');

io.httpInspectorCreate('.*', function(req) {
  req.setCookie('PREF'); // Clear the PREF cookie
  req.setCookie('what', 'woot'); // Set what = woot
});

var x = http.request('https://www.google.com/', {
  debug: true
});

Also available in: Atom PDF