reqresp.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:darkc0de-old-stuff 作者: tuwid 项目源码 文件源码
def perform(self):
        self.__performHead=""
        self.__performBody=""

        conn=pycurl.Curl()
        conn.setopt(pycurl.SSL_VERIFYPEER,False)
        conn.setopt(pycurl.SSL_VERIFYHOST,1)
        conn.setopt(pycurl.URL,self.completeUrl)

        if self.__method or self.__userpass:
            if self.__method=="basic":
                conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
            elif self.__method=="ntlm":
                conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_NTLM)
            elif self.__method=="digest":
                conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_DIGEST)
            conn.setopt(pycurl.USERPWD, self.__userpass)

        if self.__timeout:
            conn.setopt(pycurl.CONNECTTIMEOUT, self.__timeout)
            conn.setopt(pycurl.NOSIGNAL, 1)

        if self.__totaltimeout:
            conn.setopt(pycurl.TIMEOUT, self.__totaltimeout)
            conn.setopt(pycurl.NOSIGNAL, 1)

        conn.setopt(pycurl.WRITEFUNCTION, self.body_callback)
        conn.setopt(pycurl.HEADERFUNCTION, self.header_callback)

        if self.__proxy!=None:
            conn.setopt(pycurl.PROXY,self.__proxy)
            if self.__headers.has_key("Proxy-Connection"):
                del self.__headers["Proxy-Connection"]

        conn.setopt(pycurl.HTTPHEADER,self.__getHeaders())
        if self.method=="POST":
            conn.setopt(pycurl.POSTFIELDS,self.__postdata)
        conn.perform()

        rp=Response()
        rp.parseResponse(self.__performHead)
        rp.addContent(self.__performBody)

        self.response=rp

    ######### ESTE conjunto de funciones no es necesario para el uso habitual de la clase
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号