t.w.http_headers : module documentation

Part of twisted.web2 View Source

No module docstring
Function dashCapitalize Capitalize a string, making sure to treat - as a word seperator
Function casemappingify Undocumented
Function lowerify Undocumented
Class HeaderHandler HeaderHandler manages header generating and parsing functions.
Function parseDateTime Convert an HTTP date string (one of three formats) to seconds since epoch.
Class Token Undocumented
Function tokenize Tokenize a string according to normal HTTP header parsing rules.
Function split The same as str.split but works on arbitrary sequences. Too bad it's not builtin to python!
Function filterTokens Filter out instances of Token, leaving only a list of strings.
Function checkSingleToken Undocumented
Function parseKeyValue Undocumented
Function parseArgs Undocumented
Function listParser Return a function which applies 'fun' to every element in the comma-separated list
Function last Return seq[-1]
Function quoteString Undocumented
Function listGenerator Return a function which applies 'fun' to every element in the given list, then joins the result with generateList
Function generateList Undocumented
Function singleHeader Undocumented
Function generateKeyValues Undocumented
Class MimeType No class docstring; 1/1 class methods, 1/5 methods documented
Function parseAccept Undocumented
Function parseAcceptQvalue Undocumented
Function addDefaultCharset Undocumented
Function addDefaultEncoding Undocumented
Function parseContentType Undocumented
Function parseContentMD5 Undocumented
Function parseContentRange Parse a content-range header into (kind, start, end, realLength).
Function parseExpect Undocumented
Function parseExpires Undocumented
Function parseIfModifiedSince Undocumented
Function parseIfRange Undocumented
Function parseRange Undocumented
Function parseRetryAfter Undocumented
Function parseWWWAuthenticate Undocumented
Function parseAuthorization Undocumented
Function generateAccept Undocumented
Function removeDefaultEncoding Undocumented
Function generateAcceptQvalue Undocumented
Function parseCacheControl Undocumented
Function generateCacheControl Undocumented
Function generateContentRange tup is (type, start, end, len) len can be None.
Function generateDateTime Convert seconds since epoch to HTTP datetime string.
Function generateExpect Undocumented
Function generateRange Undocumented
Function generateRetryAfter Undocumented
Function generateContentType Undocumented
Function generateIfRange Undocumented
Function generateWWWAuthenticate Undocumented
Function generateAuthorization Undocumented
Class ETag Undocumented
Function parseStarOrETag Undocumented
Function generateStarOrETag Undocumented
Class Cookie Undocumented
Function parseCookie No summary
Function generateCookie Undocumented
Function parseSetCookie Undocumented
Function parseSetCookie2 Undocumented
Function makeCookieFromList Undocumented
Function generateSetCookie Undocumented
Function generateSetCookie2 Undocumented
Function parseDepth Undocumented
Function parseOverWrite Undocumented
Function generateOverWrite Undocumented
Class Headers This class stores the HTTP headers as both a parsed representation and the raw string representation. It converts between the two on demand.
Class __RecalcNeeded Undocumented
def dashCapitalize(s): (source)
Capitalize a string, making sure to treat - as a word seperator
def casemappingify(d): (source)
Undocumented
def lowerify(d): (source)
Undocumented
def parseDateTime(dateString): (source)
Convert an HTTP date string (one of three formats) to seconds since epoch.
def tokenize(header, foldCase=True): (source)

Tokenize a string according to normal HTTP header parsing rules.

In particular:
  • Whitespace is irrelevant and eaten next to special separator tokens. Its existance (but not amount) is important between character strings.
  • Quoted string support including embedded backslashes.
  • Case is insignificant (and thus lowercased), except in quoted strings. (unless foldCase=False)
  • Multiple headers are concatenated with ','

NOTE: not all headers can be parsed with this function.

Takes a raw header value (list of strings), and Returns a generator of strings and Token class instances.
def split(seq, delim): (source)
The same as str.split but works on arbitrary sequences. Too bad it's not builtin to python!
def filterTokens(seq): (source)

Filter out instances of Token, leaving only a list of strings.

Used instead of a more specific parsing method (e.g. splitting on commas) when only strings are expected, so as to be a little lenient.

Apache does it this way and has some comments about broken clients which forget commas (?), so I'm doing it the same way. It shouldn't hurt anything, in any case.
def checkSingleToken(tokens): (source)
Undocumented
def parseKeyValue(val): (source)
Undocumented
def parseArgs(field): (source)
Undocumented
def listParser(fun): (source)
Return a function which applies 'fun' to every element in the comma-separated list
def last(seq): (source)
Return seq[-1]
def quoteString(s): (source)
Undocumented
def listGenerator(fun): (source)
Return a function which applies 'fun' to every element in the given list, then joins the result with generateList
def generateList(seq): (source)
Undocumented
def singleHeader(item): (source)
Undocumented
def generateKeyValues(kvs): (source)
Undocumented
def parseAccept(field): (source)
Undocumented
def parseAcceptQvalue(field): (source)
Undocumented
def addDefaultCharset(charsets): (source)
Undocumented
def addDefaultEncoding(encodings): (source)
Undocumented
def parseContentType(header): (source)
Undocumented
def parseContentMD5(header): (source)
Undocumented
def parseContentRange(header): (source)

Parse a content-range header into (kind, start, end, realLength).

realLength might be None if real length is not known ('*'). start and end might be None if start,end unspecified (for response code 416)
def parseExpect(field): (source)
Undocumented
def parseExpires(header): (source)
Undocumented
def parseIfModifiedSince(header): (source)
Undocumented
def parseIfRange(headers): (source)
Undocumented
def parseRange(range): (source)
Undocumented
def parseRetryAfter(header): (source)
Undocumented
def parseWWWAuthenticate(tokenized): (source)
Undocumented
def parseAuthorization(header): (source)
Undocumented
def generateAccept(accept): (source)
Undocumented
def removeDefaultEncoding(seq): (source)
Undocumented
def generateAcceptQvalue(keyvalue): (source)
Undocumented
def parseCacheControl(kv): (source)
Undocumented
def generateCacheControl((k, v)): (source)
Undocumented
def generateContentRange(tup): (source)
tup is (type, start, end, len) len can be None.
def generateDateTime(secSinceEpoch): (source)
Convert seconds since epoch to HTTP datetime string.
def generateExpect(item): (source)
Undocumented
def generateRange(range): (source)
Undocumented
def generateRetryAfter(when): (source)
Undocumented
def generateContentType(mimeType): (source)
Undocumented
def generateIfRange(dateOrETag): (source)
Undocumented
def generateWWWAuthenticate(headers): (source)
Undocumented
def generateAuthorization(seq): (source)
Undocumented
def parseStarOrETag(tokens): (source)
Undocumented
def generateStarOrETag(etag): (source)
Undocumented
def parseCookie(headers): (source)
Bleargh, the cookie spec sucks. This surely needs interoperability testing. There are two specs that are supported: Version 0) http://wp.netscape.com/newsref/std/cookie_spec.html Version 1) http://www.faqs.org/rfcs/rfc2965.html
def generateCookie(cookies): (source)
Undocumented
def parseSetCookie(headers): (source)
Undocumented
def parseSetCookie2(toks): (source)
Undocumented
def makeCookieFromList(tup, netscapeFormat): (source)
Undocumented
def generateSetCookie(cookies): (source)
Undocumented
def generateSetCookie2(cookies): (source)
Undocumented
def parseDepth(depth): (source)
Undocumented
def parseOverWrite(overwrite): (source)
Undocumented
def generateOverWrite(overwrite): (source)
Undocumented
API Documentation for Twisted, generated by pydoctor at 2011-10-27 15:57:47.