MCPcopy Index your code
hub / github.com/webpy/webpy / header

Function header

web/webapi.py:385–401  ·  view source on GitHub ↗

Adds the header `hdr: value` with the response. If `unique` is True and a header with that name already exists, it doesn't add a new one.

(hdr, value, unique=False)

Source from the content-addressed store, hash-verified

383
384
385def header(hdr, value, unique=False):
386 """
387 Adds the header `hdr: value` with the response.
388
389 If `unique` is True and a header with that name already exists,
390 it doesn't add a new one.
391 """
392 hdr, value = safestr(hdr), safestr(value)
393 # protection against HTTP response splitting attack
394 if "\n" in hdr or "\r" in hdr or "\n" in value or "\r" in value:
395 raise ValueError("invalid characters in header")
396 if unique is True:
397 for h, v in ctx.headers:
398 if h.lower() == hdr.lower():
399 return
400
401 ctx.headers.append((hdr, value))
402
403
404def rawinput(method=None):

Callers 2

__init__Method · 0.85
setcookieFunction · 0.85

Calls 2

safestrFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected