def WriteHeaders(headers, outfile, content_len=None):
 wrote_content_length = False
 for (header, value) in headers.iteritems():
  if ((header.lower() == 'content-length') and (content_len is not None)):
   value = content_len
   wrote_content_length = True
  outfile.write(('%s: %s\r\n' % (header, value)))
 if ((not wrote_content_length) and content_len):
  outfile.write(('Content-Length: %s\r\n' % content_len))

def WriteHeaders ( headers , outfile , content_len = None ) : wrote_content_length = False for ( header , value ) in headers . iteritems ( ) : if ( ( header . lower ( ) == 'content-length' ) and ( content_len is not None ) ) : value = content_len wrote_content_length = True outfile . write ( ( '%s: %s\r\n' % ( header , value ) ) ) if ( ( not wrote_content_length ) and content_len ) : outfile . write ( ( 'Content-Length: %s\r\n' % content_len ) )
write headers to the output file .