当前位置: 首页>>代码示例>>Python>>正文


Python HTTPPluginControl.getThreadHTTPClientContext方法代码示例

本文整理汇总了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")
开发者ID:DealerDotCom,项目名称:grinder,代码行数:33,代码来源:cookies.py

示例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')
开发者ID:DealerDotCom,项目名称:grinder,代码行数:10,代码来源:digestauthentication.py

示例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)
开发者ID:654894017,项目名称:ngrinder,代码行数:14,代码来源:login.py

示例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
开发者ID:LeonardoXavier,项目名称:f1,代码行数:15,代码来源:send.py

示例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)
开发者ID:LeonardoXavier,项目名称:f1,代码行数:15,代码来源:send.py

示例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
开发者ID:654894017,项目名称:ngrinder,代码行数:15,代码来源:login.py

示例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")
开发者ID:yzhu1,项目名称:wgspring,代码行数:17,代码来源:authentication_util.py

示例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
开发者ID:SriramBms,项目名称:f1,代码行数:23,代码来源:send.py


注:本文中的net.grinder.plugin.http.HTTPPluginControl.getThreadHTTPClientContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。