本文整理汇总了Python中net.grinder.plugin.http.HTTPPluginControl.getConnectionDefaults方法的典型用法代码示例。如果您正苦于以下问题:Python HTTPPluginControl.getConnectionDefaults方法的具体用法?Python HTTPPluginControl.getConnectionDefaults怎么用?Python HTTPPluginControl.getConnectionDefaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.grinder.plugin.http.HTTPPluginControl
的用法示例。
在下文中一共展示了HTTPPluginControl.getConnectionDefaults方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NVPair
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getConnectionDefaults [as 别名]
# The Grinder 3.4
# HTTP script recorded by TCPProxy at Jan 24, 2011 1:53:12 PM
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPPluginControl, HTTPRequest
from HTTPClient import NVPair
connectionDefaults = HTTPPluginControl.getConnectionDefaults()
httpUtilities = HTTPPluginControl.getHTTPUtilities()
# To use a proxy server, uncomment the next line and set the host and port.
# connectionDefaults.setProxyServer("localhost", 8001)
# These definitions at the top level of the file are evaluated once,
# when the worker process is started.
connectionDefaults.defaultHeaders = \
[ NVPair('Accept-Language', 'en-us,en;q=0.5'),
NVPair('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7'),
NVPair('Accept-Encoding', 'gzip,deflate'),
NVPair('User-Agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13'), ]
headers0= \
[ NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'), ]
headers1= \
[ NVPair('Accept', 'image/png,image/*;q=0.8,*/*;q=0.5'),
NVPair('Referer', 'http://localhost:8000/oib/login'), ]
headers2= \
[ NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'),
示例2: Copyright
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getConnectionDefaults [as 别名]
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# The Grinder 3.4
# HTTP script originally recorded by TCPProxy, but then hacked...
from net.grinder.script import Test
from net.grinder.script.Grinder import grinder
from net.grinder.plugin.http import HTTPPluginControl, HTTPRequest
from HTTPClient import NVPair
from HTTPClient import Cookie, CookieModule, CookiePolicyHandler
connectionDefaults = HTTPPluginControl.getConnectionDefaults()
# Decode gzipped responses
connectionDefaults.useContentEncoding = 1
# in ms
connectionDefaults.setTimeout(60000)
httpUtilities = HTTPPluginControl.getHTTPUtilities()
log = grinder.logger.output
# Properties read from the grinder .properties file.
# After how many 'send' requests should we perform oauth? This is to
# simulate cookie expiry or session timeouts.
sends_per_oauth = grinder.getProperties().getInt("linkdrop.sends_per_oauth", 0)
示例3: __init__
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getConnectionDefaults [as 别名]
from javax.net.ssl import SSLProtocolException
from java.util import Random
from java.util.zip import InflaterOutputStream
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest, HTTPPluginControl, TimeoutException
from org.apache.commons.codec.binary import Base64
from org.json.simple import JSONValue
from time import time
from collections import deque
from threading import Lock
from HTTPClient import NVPair
log = grinder.logger.info
HTTPPluginControl.getConnectionDefaults().setFollowRedirects(2)
HTTPPluginControl.getConnectionDefaults().setTimeout(10000)
CookieHandler.setDefault(CookieManager(None, CookiePolicy.ACCEPT_ALL)) # require for LS load balancing
baseUrl = grinder.properties.getProperty("web.baseUrl")
isLogEnabled = grinder.properties.getBoolean("log.isEnabled", False)
useRabbitForGameMessages = grinder.properties.getBoolean("yazino.useRabbitForGameMessages", False)
class PlayerSource:
def __init__(self):
sessionDuration = grinder.properties.getInt("player.sessionDurationInSeconds", 0)
self.password = grinder.properties.getProperty("player.password")
players_url = grinder.properties.getProperty("player.source-url")
passwordHash = URLEncoder.encode(grinder.properties.getProperty("player.passwordHash"), "UTF-8")
workers = grinder.properties.getInt("grinder.processes", 0)
threads = grinder.properties.getInt("grinder.threads", 0)
示例4: Copyright
# 需要导入模块: from net.grinder.plugin.http import HTTPPluginControl [as 别名]
# 或者: from net.grinder.plugin.http.HTTPPluginControl import getConnectionDefaults [as 别名]
# HTTP digest authentication
#
# Basically delegates to HTTPClient's support for digest
# authentication.
#
# Copyright (C) 2008 Matt Moran
# Copyright (C) 2008 Philip Aston
# Distributed under the terms of The Grinder license.
from net.grinder.plugin.http import HTTPPluginControl
from HTTPClient import AuthorizationInfo
# Enable HTTPClient's authorisation module.
HTTPPluginControl.getConnectionDefaults().useAuthorizationModule = 1
test1 = Test(1, "Request resource")
request1 = test1.wrap(HTTPRequest())
class TestRunner:
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')