Skip to content

Commit f7eaf7b

Browse files
committed
Rev860, Re-enable ajax on non-html items
1 parent 03bfb64 commit f7eaf7b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Config(object):
88

99
def __init__(self, argv):
1010
self.version = "0.3.5"
11-
self.rev = 859
11+
self.rev = 860
1212
self.argv = argv
1313
self.action = None
1414
self.createParser()

src/Ui/UiRequest.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def route(self, path):
4949
path = re.sub("^http://", "/", path) # Remove begining http for chrome extension .bit access
5050

5151
if self.env["REQUEST_METHOD"] == "OPTIONS":
52-
self.sendHeader()
52+
content_type = self.getContentType(path)
53+
self.sendHeader(content_type=content_type)
5354
return ""
5455

5556
if path == "/":
@@ -137,8 +138,8 @@ def sendHeader(self, status=200, content_type="text/html", extra_headers=[]):
137138
headers.append(("Version", "HTTP/1.1"))
138139
headers.append(("Connection", "Keep-Alive"))
139140
headers.append(("Keep-Alive", "max=25, timeout=30"))
140-
if content_type == "application/json":
141-
headers.append(("Access-Control-Allow-Origin", "*")) # Allow json access only on json content
141+
if content_type != "text/html":
142+
headers.append(("Access-Control-Allow-Origin", "*")) # Allow json access on non-html files
142143
# headers.append(("Content-Security-Policy", "default-src 'self' data: 'unsafe-inline' ws://127.0.0.1:* http://127.0.0.1:* wss://tracker.webtorrent.io; sandbox allow-same-origin allow-top-navigation allow-scripts")) # Only local connections
143144
if self.env["REQUEST_METHOD"] == "OPTIONS":
144145
# Allow json access
@@ -380,11 +381,11 @@ def actionFile(self, file_path, block_size=64 * 1024, send_header=True):
380381
if range:
381382
range_start = int(re.match(".*?([0-9]+)", range).group(1))
382383
if re.match(".*?-([0-9]+)", range):
383-
range_end = int(re.match(".*?-([0-9]+)", range).group(1))+1
384+
range_end = int(re.match(".*?-([0-9]+)", range).group(1)) + 1
384385
else:
385386
range_end = file_size
386387
extra_headers["Content-Length"] = str(range_end - range_start)
387-
extra_headers["Content-Range"] = "bytes %s-%s/%s" % (range_start, range_end-1, file_size)
388+
extra_headers["Content-Range"] = "bytes %s-%s/%s" % (range_start, range_end - 1, file_size)
388389
if range:
389390
status = 206
390391
else:

0 commit comments

Comments
 (0)