summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2011-04-07 15:10:18 +0200
committerGravatar Martin Szulecki2011-04-07 15:10:18 +0200
commit70510e357ede9c2fd366dcfa5315c70dd11b5673 (patch)
tree72b988c9483fa17061a52e345ee76535e5922f87
parent3218ff200f946f517cfab9020001cd59319cd069 (diff)
downloadtotem-plugin-airplay-70510e357ede9c2fd366dcfa5315c70dd11b5673.tar.gz
totem-plugin-airplay-70510e357ede9c2fd366dcfa5315c70dd11b5673.tar.bz2
Allow custom headers for a response
-rw-r--r--AirPlayService.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/AirPlayService.py b/AirPlayService.py
index 3c9557c..5b4e58c 100644
--- a/AirPlayService.py
+++ b/AirPlayService.py
@@ -106,7 +106,7 @@ class AirPlayProtocolHandler(asyncore.dispatcher_with_send):
106 d, p = self.service.get_scrub() 106 d, p = self.service.get_scrub()
107 content = "duration: " + str(float(d)) 107 content = "duration: " + str(float(d))
108 content += "\nposition: " + str(float(p)) 108 content += "\nposition: " + str(float(p))
109 answer = self.create_request(200, content) 109 answer = self.create_request(200, "", content)
110 elif request.type == 'POST': 110 elif request.type == 'POST':
111 self.service.set_scrub(float(request.params['position'])) 111 self.service.set_scrub(float(request.params['position']))
112 answer = self.create_request() 112 answer = self.create_request()
@@ -131,7 +131,7 @@ class AirPlayProtocolHandler(asyncore.dispatcher_with_send):
131 datestr = today.strftime("%a, %d %b %Y %H:%M:%S") 131 datestr = today.strftime("%a, %d %b %Y %H:%M:%S")
132 return datestr+" GMT" 132 return datestr+" GMT"
133 133
134 def create_request(self, status = 200, body = ""): 134 def create_request(self, status = 200, header = "", body = ""):
135 clength = len(bytes(body)) 135 clength = len(bytes(body))
136 if (status == 200): 136 if (status == 200):
137 answer = "HTTP/1.1 200 OK" 137 answer = "HTTP/1.1 200 OK"
@@ -143,6 +143,8 @@ class AirPlayProtocolHandler(asyncore.dispatcher_with_send):
143 answer += "\nConnection: Upgrade" 143 answer += "\nConnection: Upgrade"
144 answer += "\nDate: " + self.getDateTime() 144 answer += "\nDate: " + self.getDateTime()
145 answer += "\nContent-Length: " + str(clength) 145 answer += "\nContent-Length: " + str(clength)
146 if (header != ""):
147 answer += "\n" + header
146 answer +="\n\n" 148 answer +="\n\n"
147 answer += body 149 answer += body
148 return answer 150 return answer