comparison sat/plugins/plugin_comp_file_sharing.py @ 3340:2ad14b834730

component file sharing: added `Access-Control-Expose-Headers` CORS header: without this header, the range header in response was not exposed to client. This could cause trouble is a javascript application was needing to access it.
author Goffi <goffi@goffi.org>
date Sat, 15 Aug 2020 20:28:07 +0200
parents b1e9f17fbb5a
children 12c427156cac
comparison
equal deleted inserted replaced
3339:c560aae54f5f 3340:2ad14b834730
113 return 'attachment' 113 return 'attachment'
114 114
115 def render(self, request): 115 def render(self, request):
116 request.setHeader("Access-Control-Allow-Origin", "*") 116 request.setHeader("Access-Control-Allow-Origin", "*")
117 request.setHeader("Access-Control-Allow-Methods", "OPTIONS, HEAD, GET, PUT") 117 request.setHeader("Access-Control-Allow-Methods", "OPTIONS, HEAD, GET, PUT")
118 request.setHeader("Access-Control-Allow-Headers", "Content-Type, Xmpp-File-Path, Xmpp-File-No-Http") 118 request.setHeader(
119 "Access-Control-Allow-Headers",
120 "Content-Type, Range, Xmpp-File-Path, Xmpp-File-No-Http")
119 request.setHeader("Access-Control-Allow-Credentials", "true") 121 request.setHeader("Access-Control-Allow-Credentials", "true")
122 request.setHeader("Accept-Ranges", "bytes")
123
124 request.setHeader(
125 "Access-Control-Expose-Headers",
126 "Date, Content-Length, Content-Range")
120 return super().render(request) 127 return super().render(request)
121 128
122 def render_OPTIONS(self, request): 129 def render_OPTIONS(self, request):
123 request.setResponseCode(http.OK) 130 request.setResponseCode(http.OK)
124 return b"" 131 return b""