[ grinder-Bugs-3496426 ] TCPProxy broken on https-Requests when started with -http

SourceForge.net <[email protected]> Tue, 18 Sep 2012 14:55:55 -0700
Newsgroups gmane.comp.java.grinder.devel
Message-ID <[email protected]>
Bugs item #3496426, was opened at 2012-03-02 15:34
Message generated for change (Settings changed) made by philipa
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=3496426&group_id=18598

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: TCPProxy
Group: None
>Status: Closed
Resolution: Duplicate
Priority: 5
Private: No
Submitted By: Andreas Vavra (vavra)
Assigned to: Philip Aston (philipa)
Summary: TCPProxy broken on https-Requests when started with -http

Initial Comment:
grinder 3.6, TCPProxy fails with https-Sites when TCPProxy is started with -http command line parameter, i.e. ...

java -cp $x net.grinder.TCPProxy -http > google_test.py

where $x=xbean.jar:picocontainer-2.13.6.jar:jython.jar:jsr173_1.0_api.jar:grinder.jar:grinder-xmlbeans.jar:grinder-agent.jar:asm-3.2.jar

Output in bash is:

3/3/12 12:22:37 AM (tcpproxy): Initialising as an HTTP/HTTPS proxy with the     
parameters:                                                                     
   Request filters:    HTTPRequestFilter                                        
   Response filters:   HTTPResponseFilter                                       
   Local address:      localhost:8001                                           
3/3/12 12:22:37 AM (tcpproxy): Engine initialised, listening on port 8001       
3/3/12 12:22:41 AM (tcpproxy): UNEXPECTED - No current request                  
Exception in thread "Filter thread for google.at:443->localhost:62985" java.lang.NullPointerException
	at net.grinder.plugin.http.tcpproxyfilter.ConnectionHandlerImplementation$Request.expectingResponseBody(ConnectionHandlerImplementation.java:399)
	at net.grinder.plugin.http.tcpproxyfilter.ConnectionHandlerImplementation.handleResponse(ConnectionHandlerImplementation.java:276)
	at net.grinder.plugin.http.tcpproxyfilter.ConnectionCache.response(ConnectionCache.java:110)
	at net.grinder.plugin.http.tcpproxyfilter.HTTPResponseFilter.handle(HTTPResponseFilter.java:63)
	at net.grinder.tools.tcpproxy.CompositeFilter.handle(CompositeFilter.java:49)
	at net.grinder.tools.tcpproxy.AbstractTCPProxyEngine$OutputStreamFilterTee.handle(AbstractTCPProxyEngine.java:545)
	at net.grinder.tools.tcpproxy.AbstractTCPProxyEngine$FilteredStreamThread.interruptibleRun(AbstractTCPProxyEngine.java:416)
	at net.grinder.util.thread.InterruptibleRunnableAdapter.run(InterruptibleRunnableAdapter.java:58)
	at java.lang.Thread.run(Thread.java:680)
3/3/12 12:22:45 AM (tcpproxy): Engine exited                                    

Output in google_test.py is:

# The Grinder 3.6
# HTTP script recorded by TCPProxy at Mar 3, 2012 12:22:37 AM

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.8,de-DE;q=0.6,de;q=0.4,de-AT;q=0.2'),
    NVPair('Accept-Encoding', 'gzip, deflate'),
    NVPair('User-Agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20100101 Firefox/10.0.2'),
    NVPair('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'), ]

headers0= \
  [ ]

url0 = 'https://google.at:443'

# Create an HTTPRequest for each request, then replace the
# reference to the HTTPRequest with an instrumented version.
# You can access the unadorned instance using request101.__target__.
request101 = HTTPRequest(url=url0, headers=headers0)
request101 = Test(101, 'ET /').wrap(request101)


class TestRunner:
  """A TestRunner instance is created for each worker thread."""

  # A method for each recorded page.
  def page1(self):
    """ET / (request 101)."""
    
    # Expecting 301 'Moved Permanently'
    result = request101.('/')

    return result

  def __call__(self):
    """This method is called for every run performed by the worker thread."""
    self.page1()      # ET / (request 101)


def instrumentMethod(test, method_name, c=TestRunner):
  """Instrument a method with the given Test."""
  unadorned = getattr(c, method_name)
  import new
  method = new.instancemethod(test.wrap(unadorned), None, c)
  setattr(c, method_name, method)

# Replace each method with an instrumented version.
# You can call the unadorned method using self.page1.__target__().
instrumentMethod(Test(100, 'Page 1'), 'page1')


Target in my browser (Firefox 10.0.2) was https://google.at/ (.com fails as well)

I've tried this with java1.6.0_29 on MacOS and java1.6.0_31 on Linux, both 64bit versions.

grinder 3.7.1 fails too, same exception, but different line number.

I've spent some time in java source to figure out,what goes wrong, but didn't make it :-(

I would need a fix for this as soon as possible (no matter, who "dirty"/ugly the fix is), because I'm trying to compete with The Grinder against HP/Mecury LoadRunner within our company. A code fix provided for my personal use (to compile my own version of The Grinder) would be greatly appreciated too! :-)

Regards
Andi


----------------------------------------------------------------------

Comment By: Philip Aston (philipa)
Date: 2012-03-02 23:44

Message:
Duplicate of 3484390. Fixed for next release. Temporary patch can be found
on 3484390.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=118598&aid=3496426&group_id=18598

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/