Issue #88 resolved

bug in _cphttptools.py

Anonymous created an issue

sometimes cpg.response.body is file type, so "for line in cpg.response.body: " will cause error. I modified it as below:BR

if type(cpg.response.body) == type([]):[[BR]]
  for line in cpg.response.body:[[BR]]
    wfile.write(line)[[BR]]

Reported by hou

Comments (5)

  1. Anonymous

    sorry,it should be:BR

    if type(cpg.response.body) == type([]):BR for line in cpg.response.body:BR wfile.write(line)BR elif type(cpg.response.body) == file:BR wfile.write(cpg.response.body.read())BR

    there may be cases like this in "doRequest".

  2. Anonymous

    Are generator types matched by type([]) ? I think it needs more explicit testing. You could also do this before the for line:

      if type(cpg.response.body) == file:
         cpg.response.body = [cpg.response.body.read()]
    
  3. Anonymous

    The code also raises an exception on empty (None or "" as far as I can remember) cpg.response.body which happens for example when sending HTTP redirects.

  4. Log in to comment