Skip to content

Instantly share code, notes, and snippets.

View mmalone's full-sized avatar

Michael Malone mmalone

View GitHub Profile
import operator
from django import http
def parse_etags(etag_str):
"""
Parses a string with one or several etags passed in If-None-Match and
If-Match headers by the rules in RFC 2616. Returns a list of etags
without surrounding double quotes (") and unescaped from \<CHAR>.
"""
import socket
def sockrecv(sock):
d = ''
while not d or d[-1] != '\n':
d += sock.recv(8192)
return d
"""
Copyright (c) 2008-2009, Nathan Borror
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this