Example #1
0
 def createRequest(self, op, req, outgoingData = 0):
     url = req.url().toString()
     host = req.url().host()
     if (req.url().isRelative() or req.url().scheme() == "file" or host in self.allowedHosts or url in self.allowedUrls):
         print "Requesting file: " + url
         return QNetworkAccessManager.createRequest(self, op, req, outgoingData)
     else:
         print "Dropping non-local URI request: " + url
         return QNetworkAccessManager.createRequest(self, QNetworkAccessManager.GetOperation, QNetworkRequest(QUrl()))
Example #2
0
 def _create_request(self, operation, request, data):
     self.log_post_data(data)
     reply = QNetworkAccessManager.createRequest(self,
                                                 operation,
                                                 request,
                                                 data)
     return reply
Example #3
0
    def _create_request(self, operation, request, data):
        self.log_post_data(data)
        # store the request object with the upload data
        try:
            raw_data = data.readAll()
        except AttributeError:
            original_data = backup_data = None
        else:
            original_data = self._new_buffer(raw_data)
            backup_data = self._new_buffer(raw_data)

        reply = QNetworkAccessManager.createRequest(self,
                                                    operation,
                                                    request,
                                                    original_data)
        self.logger.info('Request {0} started.'.format(id(reply)))

        if original_data is not None:
            original_data.setParent(reply)
            backup_data.setParent(reply)

        self._requests[id(reply)] = {'reply': reply,
                                     'outgoing_data': backup_data,
                                     'finished': False,
                                     'retry_count': 0}
        # in case the request object is destroyed, remove it from the dict
        # of request objects
        reply.destroyed.connect(partial(self._reply_destroyed, id(reply)))
        return reply
Example #4
0
 def _create_request(self, operation, request, data):
     reply = QNetworkAccessManager.createRequest(self.network_manager,
                                                 operation, request, data)
     url = request.url().toString()
     print(url)
     # self.resultList.append(url)
     return reply
Example #5
0
 def createRequest(self, operation, request, device=None):
     if self.headers:
         request = QNetworkRequest(request)
         if operation != QNetworkAccessManager.PostOperation and operation != QNetworkAccessManager.PutOperation :
             request.setHeader(QNetworkRequest.ContentTypeHeader, None)
         for item in self.headers.iteritems():
             request.setRawHeader(*item)
     return QNetworkAccessManager.createRequest(self,operation, request, device)
Example #6
0
 def createRequest(self, operation, request, data):
     # data contains all the post data that is being added to the request
     # so you can look into it here
     #print "replay:====>",request.url().toString(),operation     
     #url = request.url().toString()   
     reply = QNetworkAccessManager.createRequest(self, operation,request,data)      
     #if "js" in url or "gif" in url:
         #reply = QNetworkAccessManager.createRequest(self,QNetworkAccessManager.GetOperation,QNetworkRequest(QtCore.QUrl("")))  
         #reply = QNetworkAccessManager.createRequest(self, operation,request,data)        
     #else:                                           
     return reply
Example #7
0
    def _create_request(self, operation, request, data):
        try:
            raw_data = smart_str(data.peek(8192))
        except AttributeError:
            # data is None, nothing will be sent in this request
            pass
        else:
            parsed_data = '\n'.join(raw_data.split('&'))
            print parsed_data

        reply = QNetworkAccessManager.createRequest(self._network_manager,
                                                    operation,
                                                    request,
                                                    data)
        return reply
Example #8
0
 def createRequest(self, operation, request, outgoingData):
     url = request.url().toString()
     for h in request.rawHeaderList():
         pass
         #self._debug(DEBUG, "  %s: %s" % (h, request.rawHeader(h)))
     if self._url_filter:
         if url in self._url_filter:
             #self._debug(INFO, "URL filtered: %s" % url)
             request.setUrl(QUrl("about:blank"))
         else:
             pass
             #self._debug(DEBUG, "URL not filtered: %s" % url)
     #print url
     #if url == "http://v5.ele.me/":
      #request.setRawHeader("Accept-Encoding","")
     
     reply = QNetworkAccessManager.createRequest(self, operation, request, outgoingData)
     #self.emit(SIGNAL('networkRequestCreated(QNetworkReply*)'), reply)
             
     #if html[:6]=='\x1f\x8b\x08\x00\x00\x00':
     #    html=gzip.GzipFile(fileobj=StringIO(html)).read()
     return reply
Example #9
0
 def createRequest(self, op, request, outgoingData=None):
     conf = QSslConfiguration()
     conf.setProtocol(QSsl.TlsV1)
     request.setSslConfiguration(conf)
     return QNetworkAccessManager.createRequest(self, op, request, outgoingData)
Example #10
0
File: t1.py Project: zjx4041739/dlp
 def _create_request(self, operation, request, data):
     print(data.readAll())
     reply = QNetworkAccessManager.createRequest(self.network_manager,
                                                 operation, request, data)
     return reply
Example #11
0
 def createRequest(self,op,request,outgoing=None): 
     self.configureSsl(request)
     reply =  QNetworkAccessManager.createRequest(self,op,request,outgoing)
     self.attachCallbacks(reply)
     self.cacheReply(reply)
     return reply