Error Domain=NSURLErrorDomain Code=-1005 “The network connection was lost.”

前端 未结 30 3664
悲哀的现实
悲哀的现实 2020-11-22 05:51

I have an application which works fine on Xcode6-Beta1 and Xcode6-Beta2 with both iOS7 and iOS8. But with Xcode6-Beta3, Beta4, Beta5 I\'m facing network issues with iOS8 but

30条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 06:43

    My problem was on the server. I was using Python's BaseHTTPRequestHandler class and I wasn't sending a body in the response. My problem was solved when I put an empty body like the following.

    def do_POST(self):
        content_len = int(self.headers.get('Content-Length'))
        post_body = self.rfile.read(content_len)
        msg_string = post_body.decode("utf-8")
        msg_json = json.loads(msg_string)
        self.send_response(200)
        self.end_headers() #this and the following lines were missing
        self.wfile.write(b'') 
    

提交回复
热议问题