简体   繁体   中英

How get cookie from http headers

from suds import WebFault
from suds.client import Client
from cookielib import Cookie

import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.transport').setLevel(logging.DEBUG)

client = Client(url)
loginResult = client.service.Login(username, password)
print "=========================================="
print client.options.transport.cookiejar

DEBUG:suds.transport.http:sending:
URL:http://127.0.0.1:34014
HEADERS: {'SOAPAction': u'""', 'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8', 'Soapaction': u'""'}

DEBUG:suds.transport.http:received:

CODE: 200

HEADERS: {
  'set-cookie': 'srv=869aa1577003769cbff7962d77641c4ae9134ac4;Domain=...;Path=/;Version=1;Max-Age=3600',
  'content-length': '440',
  'content-type': 'text/xml; charset=utf-8',
  'connection': 'close',
  'server': 'soap/1.9'
}

==========================================

    <cookielib.CookieJar[]>

==========================================
None

If client.options.transport.cookiejar it means that cookielib can't create cookies from the response. You should look to cookie validation in the cookielib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM