Why am I getting this error in python ? (httplib)

后端 未结 10 1682
情话喂你
情话喂你 2020-11-27 20:11
if theurl.startswith(\"http://\"): theurl = theurl[7:]
    head = theurl[:theurl.find(\'/\')]
    tail = theurl[theurl.find(\'/\'):]
response_code = 0
import httplib         


        
10条回答
  •  暖寄归人
    2020-11-27 20:28

    I recently got this error, in a situation where the method that contained the http request ran successfully once, and then threw this exception (with the status code as an empty string) the second time the method was called (with a different URL). I had a debugging advantage because this is calling my own REST api, so I did some logging on the server side and discovered that the request was never being received. I ultimately figured out that my URL string had a trailing newline character. So make sure that your URLs are stripped of any leading or trailing special characters.

提交回复
热议问题