Few fixes for an Issue #79 (problem with case sensitivity of request get_header)

This commit is contained in:
Miroslav Stampar
2012-08-31 12:15:09 +02:00
parent 2806185989
commit 7286d89cb6
2 changed files with 21 additions and 8 deletions

View File

@@ -3267,3 +3267,15 @@ def prioritySortColumns(columns):
"""
_ = lambda x: x and "id" in x.lower()
return sorted(sorted(columns, key=len), lambda x, y: -1 if _(x) and not _(y) else 1 if not _(x) and _(y) else 0)
def getRequestHeader(request, name):
"""
Solving an issue with an urllib2 Request header case sensitivity
Reference: http://bugs.python.org/issue2275
"""
retVal = None
if request and name:
retVal = max(request.get_header(_) if name.upper() == _.upper() else None for _ in request.headers.keys())
return retVal