def replace_header(self, name, value):
        """
        replace header with new value or add new header
        return old header value, if any
        """
        name_lower = name.lower()
        for index in range(len(self.headers) - 1, -1, -1):
            curr_name, curr_value = self.headers[index]
            if curr_name.lower() == name_lower:
                self.headers[index] = (curr_name, value)
                return curr_value

        self.headers.append((name, value))
        return None
def replace_header ( self , name , value ) : name_lower = name . lower ( ) for index in range ( len ( self . headers ) - 1 , - 1 , - 1 ) : curr_name , curr_value = self . headers [ index ] if curr_name . lower ( ) == name_lower : self . headers [ index ] = ( curr_name , value ) return curr_value self . headers . append ( ( name , value ) ) return None
replace header with new value or add new header
        return old header value, if any