Skip to content

Commit

Permalink
Merge pull request #44 from crotwell/cors
Browse files Browse the repository at this point in the history
add CORS header in several places
  • Loading branch information
chad-earthscope authored Dec 9, 2023
2 parents e6dd310 + 0f2d801 commit 7f52aee
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 @@ -80,6 +80,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 @@ -91,6 +92,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 @@ -101,6 +103,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 @@ -168,6 +171,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 @@ -230,6 +234,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 7f52aee

Please sign in to comment.