本文整理汇总了Python中net.grinder.plugin.http.HTTPPluginControl类的典型用法代码示例。如果您正苦于以下问题:Python HTTPPluginControl类的具体用法?Python HTTPPluginControl怎么用?Python HTTPPluginControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HTTPPluginControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
def __call__(self):
c = HTTPPluginControl.getThreadConnection(url)
for baud in rates:
c.setBandwidthLimit(baud)
requests[baud].GET(url)
示例2: __call__
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")
示例3: __call__
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')
示例4: __init__
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)
示例5: __call__
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
示例6: doit
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)
示例7: getCSRF
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
示例8: setStubbornAuthToken
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")
示例9: doTest
def doTest(self, iteration):
if self.basicAuthentication:
connection = HTTPPluginControl.getThreadConnection(self.url)
connection.addBasicAuthorization(self.basicAuthentication[0],
self.basicAuthentication[1],
self.basicAuthentication[2])
grinder.statistics.delayReports = 1
if self.postData:
page = self.request.POST(self.url, self.postData).text
else:
page = self.request.GET(self.url).text
if not page:
error = self.okString
else:
error = self.okString and page.find(self.okString) == -1
if error or logHTML:
if self.test.description:
description = "_%s" % self.test.description
else:
description = ""
filename = grinder.filenameFactory.createFilename(
"page",
"_%d_%.3d%s" % (iteration, self.test.number, description))
file = open(filename, "w")
print >> file, page
file.close()
if error:
grinder.logger.error(
"The 'ok' string ('%s') was not found in the page "
"received. The output has been written to '%s'." %
(self.okString, filename))
if error:
grinder.statistics.forLastTest.success = 0
if self.sleepTime:
grinder.sleep(long(self.sleepTime))
示例10: authService
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
示例11: NVPair
# 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'),
示例12: __init__
# TODO:
# What to do about errors
# Control M's in logged data
# Timing vs G2
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPPluginControl, HTTPRequest
from HTTPClient import NVPair
pluginParameters = grinder.properties.getPropertySubset("grinder.plugin.parameter.")
# Parse global parameters.
control = HTTPPluginControl.getConnectionDefaults()
control.followRedirects = pluginParameters.getBoolean("followRedirects", 0)
control.useCookies = pluginParameters.getBoolean("useCookies", 1)
logHTML = pluginParameters.getBoolean("logHTML", 0)
if pluginParameters["disablePersistentConnections"]:
control.defaultHeaders = ( NVPair("Connection", "close"), )
class G2HTTPTest:
"""Parses parameters for an individual test and records the test
invocation using a G3 Test."""
def __init__(self, testNumber, properties):
self.sleepTime = properties["sleepTime"]
示例13: __init__
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)
示例14: Copyright
# 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)
示例15: Test
PIDPREFIX = grinder.getProperties().getProperty('pidprefix')
log = grinder.logger.output # alias
testCycle = Test(0,"Full Cycle")
test1 = Test(1, "RetrieveDC")
test2 = Test(2, "Ingest")
test3 = Test(3, "modifyRELSEXT")
test4 = Test(4, "RetrieveRELSEXT")
utilities = HTTPPluginControl.getHTTPUtilities()
auth = utilities.basicAuthorizationHeader(grinder.getProperties().getProperty('fcrepo.userName'),grinder.getProperties().getProperty('fcrepo.password'))
contenttype = NVPair('Content-Type','text/xml')
dedupobject = FileInputStream('fcagent-file-store/current/DataWellDeDup.xml')
requestDCHTTP = test1.wrap(HTTPRequest())
ingestHTTP = test2.wrap(HTTPRequest())
requestRELSEXT = test4.wrap(HTTPRequest())
def establishFirstFromFedora():
global auth
log("establish First")