MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / _process_cors

Method _process_cors

pywebio/platform/adaptor/http.py:194–202  ·  view source on GitHub ↗

Handling cross-domain requests: check the source of the request and set headers

(self, context: HttpContext)

Source from the content-addressed store, hash-verified

192 cls._webio_expire.pop(sid, None)
193
194 def _process_cors(self, context: HttpContext):
195 """Handling cross-domain requests: check the source of the request and set headers"""
196 origin = context.request_headers().get('Origin', '')
197 if self.check_origin(origin):
198 context.set_header('Access-Control-Allow-Origin', origin)
199 context.set_header('Access-Control-Allow-Methods', 'GET, POST')
200 context.set_header('Access-Control-Allow-Headers', 'content-type, webio-session-id')
201 context.set_header('Access-Control-Expose-Headers', 'webio-session-id')
202 context.set_header('Access-Control-Max-Age', str(1440 * 60))
203
204 def interval_cleaning(self):
205 # clean up at intervals

Callers 1

Calls 4

getMethod · 0.45
request_headersMethod · 0.45
check_originMethod · 0.45
set_headerMethod · 0.45

Tested by

no test coverage detected