Skip to content

Commit

Permalink
Rev860, Re-enable ajax on non-html items
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Feb 1, 2016
1 parent 03bfb64 commit f7eaf7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Config(object):

def __init__(self, argv):
self.version = "0.3.5"
self.rev = 859
self.rev = 860
self.argv = argv
self.action = None
self.createParser()
Expand Down
11 changes: 6 additions & 5 deletions src/Ui/UiRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def route(self, path):
path = re.sub("^http://", "/", path) # Remove begining http for chrome extension .bit access

if self.env["REQUEST_METHOD"] == "OPTIONS":
self.sendHeader()
content_type = self.getContentType(path)
self.sendHeader(content_type=content_type)
return ""

if path == "/":
Expand Down Expand Up @@ -137,8 +138,8 @@ def sendHeader(self, status=200, content_type="text/html", extra_headers=[]):
headers.append(("Version", "HTTP/1.1"))
headers.append(("Connection", "Keep-Alive"))
headers.append(("Keep-Alive", "max=25, timeout=30"))
if content_type == "application/json":
headers.append(("Access-Control-Allow-Origin", "*")) # Allow json access only on json content
if content_type != "text/html":
headers.append(("Access-Control-Allow-Origin", "*")) # Allow json access on non-html files
# 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
if self.env["REQUEST_METHOD"] == "OPTIONS":
# Allow json access
Expand Down Expand Up @@ -380,11 +381,11 @@ def actionFile(self, file_path, block_size=64 * 1024, send_header=True):
if range:
range_start = int(re.match(".*?([0-9]+)", range).group(1))
if re.match(".*?-([0-9]+)", range):
range_end = int(re.match(".*?-([0-9]+)", range).group(1))+1
range_end = int(re.match(".*?-([0-9]+)", range).group(1)) + 1
else:
range_end = file_size
extra_headers["Content-Length"] = str(range_end - range_start)
extra_headers["Content-Range"] = "bytes %s-%s/%s" % (range_start, range_end-1, file_size)
extra_headers["Content-Range"] = "bytes %s-%s/%s" % (range_start, range_end - 1, file_size)
if range:
status = 206
else:
Expand Down

0 comments on commit f7eaf7b

Please sign in to comment.