Python set default headers
28 Python code examples are found related to "
set default headers".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: base.py From politicos with GNU Affero General Public License v3.0 | 5 votes |
def set_default_headers(self): self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Headers', 'x-requested-with') self.set_header('Access-Control-Allow-Methods', 'GET, OPTIONS') self.set_header( 'Access-Control-Allow-Headers', 'access-control-allow-origin,authorization,content-type' )
Example 2
Source File: web.py From V1EngineeringInc-Docs with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
def set_default_headers(self) -> None: """Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling. """ pass
Example 3
Source File: web.py From EventGhost with GNU General Public License v2.0 | 5 votes |
def set_default_headers(self): """Override this to set HTTP headers at the beginning of the request. For example, this is the place to set a custom ``Server`` header. Note that setting such headers in the normal flow of request processing may not do what you want, since headers may be reset during error handling. """ pass
Example 4
Source File: main.py From autoops with Apache License 2.0 | 5 votes |
def set_default_headers(self): self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') self.set_header('Access-Control-Max-Age', 1000) self.set_header('Access-Control-Allow-Headers', '*') self.set_header('Content-type', 'application/json')
Example 5
Source File: webapi.py From cate with MIT License | 5 votes |
def set_default_headers(self) -> None: self.set_header("Access-Control-Allow-Origin", "*") self.set_header("Access-Control-Allow-Headers", "x-requested-with") self.set_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS') self.set_header('User-Agent', f'Cate WebAPI/{__version__}')
Example 6
Source File: base_handler.py From OpenScraper with MIT License | 5 votes |
def set_default_headers(self): """ set some handlers to be able to respond to AJAX GET queries with CORS protection cf : https://stackoverflow.com/questions/35254742/tornado-server-enable-cors-requests """ headers = self.request.headers # .get('Origin') app_log.info("HHH --> headers : \n %s ", pformat(headers.__dict__)) # app_log.info("setting headers") self.set_header("Access-Control-Allow-Origin", "*") self.set_header("Access-Control-Allow-Credentials", True ) # self.set_header("Access-Control-Allow-Headers", "x-requested-with") # self.set_header("Access-Control-Request-Headers", "x-test-header") # self.set_header("Access-Control-Request-Headers", "x-test-header") # self.set_header("Access-Control-Expose-Headers", "x-test-header") # self.set_header("Access-Control-Allow-Headers", "x-requested-with") self.set_header("Access-Control-Allow-Headers", # "accept,access-control-allow-origin,access-control-allow-credentials,authorization,content-type" "accept,access-control-allow-origin,access-control-allow-credentials,Access-Control-Request-Headers,authorization,content-type,x-token-header" ) # self.set_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS") self.set_header("Access-Control-Allow-Methods", "GET,OPTIONS")
Example 7
Source File: httpapi.py From synapse with Apache License 2.0 | 5 votes |
def set_default_headers(self): origin = self.request.headers.get('origin') if origin is not None and self.isOrigHost(origin): self.add_header('Access-Control-Allow-Origin', origin) self.add_header('Access-Control-Allow-Credentials', 'true') self.add_header('Access-Control-Allow-Headers', 'Content-Type')
Example 8
Source File: webserver.py From Scanver with Apache License 2.0 | 5 votes |
def set_default_headers(self): self.set_header("X-Powered-By","PHP/6.6.6") self.set_header("Server","Apache/6.6.6") self.set_header("Date","EMM, 00 SB 2333 00:00:00 MMM") if DEBUG: self.set_header("Access-Control-Allow-Credentials","true") self.set_header("Access-Control-Allow-Origin","*")
Example 9
Source File: base.py From opencanary_web with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_default_headers(self): self.set_header('Access-Control-Allow-Origin', '*') # 这个地方可以写域名 self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') self.set_header('Access-Control-Max-Age', 1000) self.set_header('Access-Control-Allow-Headers', 'Content-Type, Authorization') self.set_header("Server","Apache-Coyote/1.1")
Example 10
Source File: basehandler.py From streamingbandit with MIT License | 5 votes |
def set_default_headers(self): origin = self.request.headers.get('Origin') self.set_header('Access-Control-Allow-Headers', 'origin, content-type, accept, authorization, x-total-count, content-range') self.set_header("Access-Control-Allow-Origin", "" if (origin==None) else origin) self.set_header("Access-Control-Allow-Credentials", 'true') self.set_header('Access-Control-Allow-Methods', 'GET, PUT, POST, DELETE, OPTIONS') self.set_header('Content-Type', 'application/json')
Example 11
Source File: handler.py From adminset with GNU General Public License v2.0 | 5 votes |
def set_default_headers(self): for header in self.custom_headers.items(): self.set_header(*header) self.set_header("Access-Control-Allow-Origin", "*") self.set_header("Access-Control-Allow-Headers", "x-requested-with") self.set_header('Access-Control-Allow-Methods', 'GET, POST')
Example 12
Source File: cluster_base_handler.py From ClusterRunner with Apache License 2.0 | 5 votes |
def set_default_headers(self): self.set_header('Content-Type', 'application/json') self.set_header(SessionId.SESSION_HEADER_KEY, SessionId.get()) request_origin = self.request.headers.get('Origin') # usually only set when making API request from a browser if request_origin and self._is_request_origin_allowed(request_origin): self.set_header('Access-Control-Allow-Origin', request_origin) self.set_header( 'Access-Control-Allow-Headers', 'Content-Type, Accept, X-Requested-With, Session, Session-Id', ) self.set_header('Access-Control-Allow-Methods', 'GET')
Example 13
Source File: httpserver.py From pypot with GNU General Public License v3.0 | 5 votes |
def set_default_headers(self): self.set_header('Cache-control', 'no-store') self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Headers', 'Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token') self.set_header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
Example 14
Source File: rebar.py From flask-rebar with MIT License | 5 votes |
def set_default_headers_schema(self, headers_schema): """ Sets the schema to be used by default to validate incoming headers. :param marshmallow.Schema headers_schema: """ self.default_headers_schema = headers_schema
Example 15
Source File: web.py From tornado-zh with MIT License | 5 votes |
def set_default_headers(self): """复写这个方法可以在请求开始的时候设置HTTP头. 例如, 在这里可以设置一个自定义 ``Server`` 头. 注意在一般的 请求过程流里可能不会实现你预期的效果, 因为头部可能在错误处 理(error handling)中被重置. """ pass
Example 16
Source File: server.py From webthing-python with Mozilla Public License 2.0 | 5 votes |
def set_default_headers(self, *args, **kwargs): """Set the default headers for all requests.""" self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept') self.set_header('Access-Control-Allow-Methods', 'GET, HEAD, PUT, POST, DELETE')
Example 17
Source File: BaseHandlers.py From SpoofcheckSelfTest with Apache License 2.0 | 5 votes |
def set_default_headers(self): ''' Set security HTTP headers ''' self.set_header("Server", "'; DROP TABLE server_types;--") self.add_header("X-Frame-Options", "DENY") self.add_header("X-XSS-Protection", "1; mode=block") self.add_header("X-Content-Type-Options", "nosniff") self._refresh_csp()
Example 18
Source File: util.py From dokomoforms with GNU General Public License v3.0 | 5 votes |
def set_default_headers(self): """Add some security-flavored headers. https://news.ycombinator.com/item?id=10143082 """ super().set_default_headers() self.clear_header('Server') self.set_header('X-Frame-Options', 'DENY') self.set_header('X-Xss-Protection', '1; mode=block') self.set_header('X-Content-Type-Options', 'nosniff') self.set_header( 'Content-Security-Policy', "script-src 'self' 'unsafe-inline' 'unsafe-eval'" " cdn.leafletjs.com code.highcharts.com" " momentjs.com cdn.datatables.net https://login.persona.org; " "child-src login.persona.org; " "frame-src login.persona.org; " "style-src 'self' 'unsafe-inline'" " fonts.googleapis.com cdn.leafletjs.com *.cloudfront.net;" "font-src 'self' fonts.googleapis.com fonts.gstatic.com;" "img-src 'self' *.tile.openstreetmap.org data: blob:;" "object-src 'self' blob:;" "media-src 'self' blob: mediastream:;" "connect-src 'self' blob: revisit.global *.revisit.global" " localhost:3000;" "default-src 'self';" )
Example 19
Source File: base.py From binderhub with BSD 3-Clause "New" or "Revised" License | 5 votes |
def set_default_headers(self): headers = self.settings.get('headers', {}) for header, value in headers.items(): self.set_header(header, value) self.set_header("access-control-allow-headers", "cache-control")
Example 20
Source File: server.py From python-sensor with MIT License | 5 votes |
def set_default_headers_with_instana(wrapped, instance, argv, kwargs): if not hasattr(instance.request, '_instana'): return wrapped(*argv, **kwargs) scope = instance.request._instana tornado_tracer.inject(scope.span.context, opentracing.Format.HTTP_HEADERS, instance._headers) instance.set_header(name='Server-Timing', value="intid;desc=%s" % scope.span.context.trace_id)
Example 21
Source File: service.py From xcube with MIT License | 5 votes |
def set_default_headers(self): self.set_header('Server', f'xcube-server/{version}') self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Methods', 'GET,PUT,DELETE,OPTIONS') self.set_header('Access-Control-Allow-Headers', 'x-requested-with,access-control-allow-origin,authorization,content-type') # noinspection PyUnusedLocal
Example 22
Source File: main.py From chain with Apache License 2.0 | 5 votes |
def set_default_headers(self): ##修改源代码的地方 self.set_header('Access-Control-Allow-Origin', '*') self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') self.set_header('Access-Control-Max-Age', 1000) self.set_header('Access-Control-Allow-Headers', '*') self.set_header('Content-type', 'application/json')
Example 23
Source File: views.py From tornado-swirl with MIT License | 5 votes |
def set_default_headers(self): headers = settings.default_settings.get( 'swagger_ui_handlers_headers', []) # type: list for (key, value) in headers: self.add_header(key, value)