本文整理汇总了Python中PyQt5.QtNetwork.QNetworkRequest.rawHeader方法的典型用法代码示例。如果您正苦于以下问题:Python QNetworkRequest.rawHeader方法的具体用法?Python QNetworkRequest.rawHeader怎么用?Python QNetworkRequest.rawHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtNetwork.QNetworkRequest
的用法示例。
在下文中一共展示了QNetworkRequest.rawHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createRequest
# 需要导入模块: from PyQt5.QtNetwork import QNetworkRequest [as 别名]
# 或者: from PyQt5.QtNetwork.QNetworkRequest import rawHeader [as 别名]
def createRequest(self, op, request, outgoingData=None):
"""
Public method to create a request.
@param op the operation to be performed
(QNetworkAccessManager.Operation)
@param request reference to the request object (QNetworkRequest)
@param outgoingData reference to an IODevice containing data to be sent
(QIODevice)
@return reference to the created reply object (QNetworkReply)
"""
scheme = request.url().scheme()
if scheme == "https" and \
(not SSL_AVAILABLE or not QSslSocket.supportsSsl()):
from .NetworkProtocolUnknownErrorReply import \
NetworkProtocolUnknownErrorReply
return NetworkProtocolUnknownErrorReply(scheme, self)
import Helpviewer.HelpWindow
if op == QNetworkAccessManager.PostOperation and \
outgoingData is not None:
outgoingDataByteArray = outgoingData.peek(1024 * 1024)
Helpviewer.HelpWindow.HelpWindow.passwordManager().post(
request, outgoingDataByteArray)
reply = None
if scheme in self.__schemeHandlers:
reply = self.__schemeHandlers[scheme]\
.createRequest(op, request, outgoingData)
if reply is not None:
return reply
# give GreaseMonkey the chance to create a request
reply = Helpviewer.HelpWindow.HelpWindow.greaseMonkeyManager()\
.createRequest(op, request, outgoingData)
if reply is not None:
return reply
req = QNetworkRequest(request)
if req.rawHeader(b"X-Eric6-UserLoadAction") == QByteArray(b"1"):
req.setRawHeader(b"X-Eric6-UserLoadAction", QByteArray())
req.setAttribute(QNetworkRequest.User + 200, "")
else:
req.setAttribute(
QNetworkRequest.User + 200, req.rawHeader(b"Referer"))
if hasattr(QNetworkRequest, 'HttpPipeliningAllowedAttribute'):
req.setAttribute(
QNetworkRequest.HttpPipeliningAllowedAttribute, True)
if not self.__acceptLanguage.isEmpty():
req.setRawHeader(b"Accept-Language", self.__acceptLanguage)
# AdBlock code
if op == QNetworkAccessManager.GetOperation:
if self.__adblockNetwork is None:
self.__adblockNetwork = \
Helpviewer.HelpWindow.HelpWindow.adBlockManager().network()
reply = self.__adblockNetwork.block(req)
if reply is not None:
reply.setParent(self)
return reply
# set cache policy
if op == QNetworkAccessManager.GetOperation:
urlHost = req.url().host()
for host in Preferences.getHelp("NoCacheHosts"):
if host in urlHost:
req.setAttribute(
QNetworkRequest.CacheLoadControlAttribute,
QNetworkRequest.AlwaysNetwork)
break
else:
req.setAttribute(
QNetworkRequest.CacheLoadControlAttribute,
Preferences.getHelp("CachePolicy"))
else:
req.setAttribute(
QNetworkRequest.CacheLoadControlAttribute,
QNetworkRequest.AlwaysNetwork)
# Do Not Track feature
if self.__doNotTrack:
req.setRawHeader(b"DNT", b"1")
req.setRawHeader(b"X-Do-Not-Track", b"1")
# Send referer header?
if not self.__sendReferer and \
req.url().host() not in Preferences.getHelp("SendRefererWhitelist"):
req.setRawHeader(b"Referer", b"")
reply = QNetworkAccessManager.createRequest(
self, op, req, outgoingData)
self.requestCreated.emit(op, req, reply)
return reply