Skip to content

Reversed variable names to get icap response line (name, value)#3

Open
ifrido wants to merge 1 commit into
vrasneur:masterfrom
ifrido:master
Open

Reversed variable names to get icap response line (name, value)#3
ifrido wants to merge 1 commit into
vrasneur:masterfrom
ifrido:master

Conversation

@ifrido

@ifrido ifrido commented Mar 9, 2017

Copy link
Copy Markdown

According to my tests the module failed when calling conn.getresponse() in Python:

>>> resp = conn.getresponse()
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 icapclient.ICAPException: Cannot parse the ICAP response line

This happened because the two variable names (name and value) have been reversed.
After exchanging them, placing "name" in the if statement and "value" where "line" is assigned it worked.
Here a working sample output with some debug info:

>>> import icapclient
>>> conn = icapclient.ICAPConnection('xxx.xxx.xxx.xxx')
>>> conn.request('REQMOD', '/tmp/test.txt')
>>> resp = conn.getresponse()
idx: '0', name: '', value: 'ICAP/1.0 204 No modifications needed'
idx: '1', name: 'X-Apparent-Data-Types', value: 'ASCII'
idx: '2', name: 'X-ICAP-Metadata', value: '{ "expect_sandbox": false }'
idx: '3', name: 'Service', value: 'CAS 1.3.7.1(190497)'
idx: '4', name: 'Service-ID', value: 'avscanner'
idx: '5', name: 'ISTag', value: '"58C0DCDA"'
idx: '6', name: 'Encapsulated', value: 'null-body=0'
idx: '7', name: 'Date', value: 'Thu, 09 Mar 2017 07:20:12 GMT'
line: 'ICAP/1.0 204 No modifications needed'
idx: '0', name: '', value: 'POST / HTTP/1.1'
idx: '1', name: 'Host', value: 'localhost'
idx: '2', name: 'Transfer-Encoding', value: 'chunked'
>>> conn.close()
>>>

To get the ICAP response line we have to check against the empty name variable, if this is true we assign the "value" variable: idx: '0', name: '', value: 'ICAP/1.0 204 No modifications needed'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant