def test_req_id_passthrough(app, client): RequestID(app) request_id = "test-request-id2" r = client.get("/", headers={'X-Request-ID': request_id}) assert r.status_code == 200 assert r.headers['X-Request-ID'] == request_id assert r.data.decode("utf-8") == request_id
def test_req_id_custom_generator(app, client): RequestID(app, header_name="App-Request-ID", generator_func=_custom_generator) r = client.get("/") assert r.status_code == 200 assert r.headers['App-Request-ID'] == "test-request-id" assert r.data.decode("utf-8") == "test-request-id"
from collections import OrderedDict import logging from os.path import abspath, dirname import sys from urllib import urlencode from urlparse import urlparse from flask import Flask, request, abort, json from flask_request_id import RequestID import requests from lxml import etree app = Flask(__name__) app.debug = False fl_req_id = RequestID(app) @app.route("/") def hello(): return """ Solve some captchas <br> <ol> <li><a href ='/amz_get_cap' >amazon</a></li> </ol> """ if __name__ == "__main__": app.run()
def test_req_id_custom_header_name(app, client): RequestID(app, header_name="App-Request-ID") r = client.get("/") assert r.status_code == 200 assert r.headers['App-Request-ID'] assert r.data.decode("utf-8") == r.headers['App-Request-ID']
def test_req_id_default(app, client): RequestID(app) r = client.get("/") assert r.status_code == 200 assert r.headers['X-Request-ID'] assert r.data.decode("utf-8") == r.headers['X-Request-ID']
import os from datacube_wms.wms import handle_wms from datacube_wms.wcs import handle_wcs from datacube_wms.ogc_exceptions import OGCException, WCS1Exception, WMSException from datacube_wms.wms_layers import get_service_cfg import logging # pylint: disable=invalid-name, broad-except _LOG = logging.getLogger(__name__) app = Flask(__name__.split('.')[0]) RequestID(app) if os.environ.get("prometheus_multiproc_dir", False): from datacube_wms.metrics.prometheus import setup_prometheus setup_prometheus(app) def lower_get_args(): # Get parameters in WMS are case-insensitive, and intended to be single use. # Spec does not specify which instance should be used if a parameter is provided more than once. # This function uses the LAST instance. d = {} for k in request.args.keys(): kl = k.lower() for v in request.args.getlist(k): d[kl] = v