forked from elmau/empresa-libre
Mostrar el request enviado
This commit is contained in:
parent
121831a139
commit
825e23e369
|
@ -42,6 +42,23 @@ logging.getLogger('requests').setLevel(logging.ERROR)
|
||||||
TIMEOUT = 10
|
TIMEOUT = 10
|
||||||
|
|
||||||
|
|
||||||
|
def pretty_print_POST(req):
|
||||||
|
"""
|
||||||
|
At this point it is completely built and ready
|
||||||
|
to be fired; it is "prepared".
|
||||||
|
|
||||||
|
However pay attention at the formatting used in
|
||||||
|
this function because it is programmed to be pretty
|
||||||
|
printed and may differ from the actual request.
|
||||||
|
"""
|
||||||
|
print('{}\n{}\r\n{}\r\n\r\n{}'.format(
|
||||||
|
'-----------START-----------',
|
||||||
|
req.method + ' ' + req.url,
|
||||||
|
'\r\n'.join('{}: {}'.format(k, v) for k, v in req.headers.items()),
|
||||||
|
req.body,
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
class PACComercioDigital(object):
|
class PACComercioDigital(object):
|
||||||
ws = 'https://{}.comercio-digital.mx/{}'
|
ws = 'https://{}.comercio-digital.mx/{}'
|
||||||
api = 'https://app2.comercio-digital.mx/{}'
|
api = 'https://app2.comercio-digital.mx/{}'
|
||||||
|
@ -91,6 +108,7 @@ class PACComercioDigital(object):
|
||||||
headers['host'] = url.split('/')[2]
|
headers['host'] = url.split('/')[2]
|
||||||
headers['Content-type'] = 'text/plain'
|
headers['Content-type'] = 'text/plain'
|
||||||
headers['Connection'] = 'Keep-Alive'
|
headers['Connection'] = 'Keep-Alive'
|
||||||
|
headers['Expect'] = '100-continue'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = requests.post(url, data=data, headers=headers, timeout=TIMEOUT)
|
result = requests.post(url, data=data, headers=headers, timeout=TIMEOUT)
|
||||||
|
@ -251,6 +269,11 @@ class PACComercioDigital(object):
|
||||||
|
|
||||||
url = self.URL['cancelxml']
|
url = self.URL['cancelxml']
|
||||||
headers = self._get_headers_cancel_xml(cfdi, info, auth)
|
headers = self._get_headers_cancel_xml(cfdi, info, auth)
|
||||||
|
|
||||||
|
req = requests.Request('POST', url, headers=headers, data=xml)
|
||||||
|
prepared = req.prepare()
|
||||||
|
pretty_print_POST(prepared)
|
||||||
|
|
||||||
result = self._post(url, xml, headers)
|
result = self._post(url, xml, headers)
|
||||||
|
|
||||||
if result is None:
|
if result is None:
|
||||||
|
|
Loading…
Reference in New Issue