FAQ  •  Register  •  Login

http header values

<<

jhb50

DLNA master

Posts: 2854

Joined: Thu Jun 30, 2011 9:32 pm

Post Wed Dec 19, 2012 9:37 pm

http header values

In order to access websites with domain protection, I need to set the Referer: value in the http header .

Your String openURL(URL url, String userAgent, Map<String,String> cookies) correctly sets the UserAgent:
but when I set
def cookies = [Referer: "http://www.cricfree.tv"]
wireshark shows the header as
Cookies: Referer=http://www.cricfree.tv\r\n
rather than the required
Referer: http://www.cricfree.tv\r\n

How do I set the Referer value?
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 16505

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Wed Dec 19, 2012 11:51 pm

Re: http header values

There is no shared method supporting custom headers. You will have to use a low level Java code to make the request. Try URLConnection and its setRequestProperty()

http://docs.oracle.com/javase/6/docs/ap ... .String%29
<<

r-win

User avatar

DLNA master

Posts: 100

Joined: Sun May 22, 2011 6:16 am

Location: Lelystad, Netherlands

Post Thu Dec 20, 2012 10:53 am

Re: http header values

I've had to use something similar to be able to POST to websites. You can find that here:
https://github.com/r-win/serviio-plugins/blob/master/OmroepNL.groovy#L64

I know I don't set any headers there, because they're not required. In your case, you can just add a line:
  Code:
connection.addRequestProperty('Referer', 'http://www.cricfree.tv')
Linksys WRT320N | Samsung PS-50C7700 | Microsoft XBOX 360 | Windows 8.1 | Linux Ubuntu 13.04
<<

jhb50

DLNA master

Posts: 2854

Joined: Thu Jun 30, 2011 9:32 pm

Post Thu Dec 20, 2012 12:44 pm

Re: http header values

Much appreciated. Thank you both. It works great.

Return to Plugin development

Who is online

Users browsing this forum: No registered users and 3 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.