Skip to content

Commit

Permalink
add CORS header in several places
Browse files Browse the repository at this point in the history
  • Loading branch information
crotwell committed Dec 8, 2023
1 parent 6116bb9 commit 0f2d801
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions portable_fdsnws_dataselect/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def return_error(self, code, err_msg):
datetime.datetime.now().isoformat(), version[0], version[1], version[2])
self.send_response(code)
self.send_header('Content-type', 'text/plain')
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Connection', 'close')
self.end_headers()
self.wfile.write(msg.encode("utf8"))
Expand All @@ -96,6 +97,7 @@ def return_version(self):
"""
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
message = "%d.%d.%d\n" % version
self.wfile.write(message.encode("utf8"))
Expand All @@ -106,6 +108,7 @@ def return_wadl(self):
"""
self.send_response(200)
self.send_header('Content-type', 'application/xml')
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
server_port = ""
if self.server.server_port != 80:
Expand Down Expand Up @@ -173,6 +176,7 @@ def common_process(self, request):

self.send_response(200)
self.send_header('Content-Type', 'text/plain')
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()

summary = "#{0:<7s}{1:<8s}{2:<8s}{3:<8s}{4:<28s}{5:<28s}{6:<20s}\n".format(
Expand Down Expand Up @@ -235,6 +239,7 @@ def common_process(self, request):
# If this is the first segment to be written, add the response headers first
if total_bytes == 0:
self.send_response(200)
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Content-Type', 'application/vnd.fdsn.mseed')
self.send_header('Content-Disposition',
'attachment; filename=fdsnws-dataselect_%s.mseed' % request_time_str)
Expand Down

0 comments on commit 0f2d801

Please sign in to comment.