def setNoCacheAndCORSHeaders(request, response): """Set Cache-Control, CORS and Content-Type headers appropriate for the cookie tests."""
headers = [(b"Content-Type", b"application/json"),
(b"Access-Control-Allow-Credentials", b"true")]
origin = b"*" if b"origin"in request.headers:
origin = request.headers[b"origin"]
def makeCookieHeader(name, value, otherAttrs): """Make a Set-Cookie header for a cookie with the name, value and attributes provided.""" def makeAV(a, v): ifNone == v or b"" == v: return a if isinstance(v, int): return b"%s=%i" % (a, v) else: return b"%s=%s" % (a, v)
# ensure cookie name is always first
attrs = [b"%s=%s" % (name, value)]
attrs.extend(makeAV(a, v) for (a, v) in otherAttrs.items()) return (b"Set-Cookie", b"; ".join((attrs)))
def readParameter(request, paramName, requireValue): """Read a parameter from the request. Raise if requireValue is set and the
parameter has an empty value orisnot present."""
params = parse_qs(request.url_parts.query)
param = params[paramName][0].strip() if len(param) == 0: raise Exception(u"Empty or missing name parameter.") return isomorphic_encode(param)
def readCookies(request): """Read the cookies from the client present in the request."""
cookies = {} for key in request.cookies: for cookie in request.cookies.get_list(key): # do we care we'll clobber cookies here? If so, do we # need to modify the test to take cookie names and value lists?
cookies[key] = cookie.value return cookies
Messung V0.5
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.