def http_form_post_message(message, location, relay_state='', typ='SAMLRequest'):
 response = ['<head>', '<title>SAML 2.0 POST</title>', '</head><body>']
 if (not isinstance(message, basestring)):
  message = ('%s' % (message,))
 if ((typ == 'SAMLRequest') or (typ == 'SAMLResponse')):
  _msg = base64.b64encode(message)
 else:
  _msg = message
 response.append((FORM_SPEC % (location, typ, _msg, relay_state)))
 response.append('<script type="text/javascript">')
 response.append('     window.onload = function ()')
 response.append(' { document.forms[0].submit(); }')
 response.append('</script>')
 response.append('</body>')
 return {'headers': [('Content-type', 'text/html')], 'data': response}

def http_form_post_message ( message , location , relay_state = '' , typ = 'SAMLRequest' ) : response = [ '<head>' , '<title>SAML 2.0 POST</title>' , '</head><body>' ] if ( not isinstance ( message , basestring ) ) : message = ( '%s' % ( message , ) ) if ( ( typ == 'SAMLRequest' ) or ( typ == 'SAMLResponse' ) ) : _msg = base64 . b64encode ( message ) else : _msg = message response . append ( ( FORM_SPEC % ( location , typ , _msg , relay_state ) ) ) response . append ( '<script type="text/javascript">' ) response . append ( '     window.onload = function ()' ) response . append ( ' { document.forms[0].submit(); }' ) response . append ( '</script>' ) response . append ( '</body>' ) return { 'headers' : [ ( 'Content-type' , 'text/html' ) ] , 'data' : response }
the http post binding defines a mechanism by which saml protocol messages may be transmitted within the base64-encoded content of a html form control .