本文整理汇总了Python中net.grinder.plugin.http.HTTPPluginControl.getThreadHTTPClientContext方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPPluginControl.getThreadHTTPClientContext方法的具体用法?Python HTTPPluginControl.getThreadHTTPClientContext怎么用?Python HTTPPluginControl.getThreadHTTPClientContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.grinder.plugin.http.HTTPPluginControl
的用法示例。
在下文中一共展示了HTTPPluginControl.getThreadHTTPClientContext方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def __call__(self):
# The cache of cookies for each worker thread will be reset at
# the start of each run.
result = request1.GET("http://localhost:7001/console/?request1")
# If the first response set any cookies for the domain,
# they willl be sent back with this request.
result2 = request1.GET("http://localhost:7001/console/?request2")
# Now let's add a new cookie.
threadContext = HTTPPluginControl.getThreadHTTPClientContext()
expiryDate = Date()
expiryDate.year += 10
cookie = Cookie("key", "value","localhost", "/", expiryDate, 0)
CookieModule.addCookie(cookie, threadContext)
result = request1.GET("http://localhost:7001/console/?request3")
# Get all cookies for the current thread and write them to the log
cookies = CookieModule.listAllCookies(threadContext)
for c in cookies: log("retrieved cookie: %s" % c)
# Remove any cookie that isn't ours.
for c in cookies:
if c != cookie: CookieModule.removeCookie(c, threadContext)
result = request1.GET("http://localhost:7001/console/?request4")
示例2: __call__
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def __call__(self):
threadContextObject = HTTPPluginControl.getThreadHTTPClientContext()
# Set the authorisation details for this worker thread.
AuthorizationInfo.addDigestAuthorization(
"www.my.com", 80, "myrealm", "myuserid", "mypw", threadContextObject)
result = request1.GET('http://www.my.com/resource')
示例3: __init__
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def __init__(self):
# Login URL
request = HTTPRequest(url="https://login.site.com")
##### reset to the all cookies #####
threadContext = HTTPPluginControl.getThreadHTTPClientContext()
self.cookies = CookieModule.listAllCookies(threadContext)
for c in self.cookies: CookieModule.removeCookie(c, threadContext)
# do login
request.POST("/login/do", ( NVPair("id", "my_id"),NVPair("pw", "my_passwd")));
##### save to the login info in cookies #####
self.cookies = CookieModule.listAllCookies(threadContext)
示例4: getCSRF
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def getCSRF():
threadContext = HTTPPluginControl.getThreadHTTPClientContext()
CookieModule.discardAllCookies(threadContext)
result = request1.GET(linkdrop_host + '/api/account/get')
assert result.getStatusCode()==200, result
csrf = linkdrop = None
for cookie in CookieModule.listAllCookies(threadContext):
if cookie.name == "linkdrop":
linkdrop = cookie
if cookie.name == "csrf":
csrf = cookie.value
assert csrf and linkdrop
return csrf, linkdrop
示例5: doit
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def doit(self):
if linkdrop_static_per_send:
for i in range(0,linkdrop_static_per_send):
getStatic(linkdrop_static_url)
if self.csrf is None or \
(sends_per_oauth and grinder.getRunNumber() % sends_per_oauth==0):
self.csrf, self.linkdrop_cookie = getCSRF()
self.userid = authService(self.csrf)
# cookies are reset by the grinder each test run - re-inject the
# linkdrop session cookie.
threadContext = HTTPPluginControl.getThreadHTTPClientContext()
CookieModule.addCookie(self.linkdrop_cookie, threadContext)
send(self.userid, self.csrf)
示例6: __call__
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def __call__(self):
grinder.statistics.delayReports = 1
##### Set to the cookies for login #####
threadContext = HTTPPluginControl.getThreadHTTPClientContext()
for c in self.cookies: CookieModule.addCookie(c,threadContext)
##### Request with login #####
result = request1.GET("/mypage")
if result.text.count("only my content data") < 0:
grinder.statistics.forLastTest.success = 0
else :
grinder.statistics.forLastTest.success = 1
示例7: setStubbornAuthToken
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def setStubbornAuthToken():
threadContext = HTTPPluginControl.getThreadHTTPClientContext()
cookies = CookieModule.listAllCookies(threadContext)
for cookie in cookies:
if cookie.getName() == 'sso.auth_token':
CookieModule.removeCookie(cookie, threadContext)
expiryDate = Date()
expiryDate.year += 10
stubbornAuthToken = StubbornCookie('sso.auth_token', cookie.getValue(),
'.wgenhq.net', '/', expiryDate, False)
CookieModule.addCookie(stubbornAuthToken, threadContext)
grinder.logger.output("Replaced sso.auth_token with a stubborn version of itself")
示例8: authService
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getThreadHTTPClientContext [as 别名]
def authService():
threadContext = HTTPPluginControl.getThreadHTTPClientContext()
CookieModule.discardAllCookies(threadContext)
# Call authorize requesting we land back on /account/get - after
# a couple of redirects for auth, we should wind up with the data from
# account/get - which should now include our account info.
result = request1.POST(linkdrop_host + '/api/account/authorize',
(
NVPair('domain', linkdrop_service),
NVPair('end_point_success', '/api/account/get'),
NVPair('end_point_auth_failure', '/current/send/auth.html#oauth_failure'), ),
( NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))
assert result.getStatusCode()==200, result
data = json_loads(result.getText())
assert data, 'account/get failed to return data'
userid = data[0]['accounts'][0]['userid']
for cookie in CookieModule.listAllCookies(threadContext):
if cookie.name == "linkdrop":
linkdrop_cookie = cookie
assert linkdrop_cookie
return userid, linkdrop_cookie