Export to GitHub

mockwebserver - issue #2

Feature Request: Need A Way To Get the Number of Socket Connections Made since Startup


Posted on Jun 28, 2012 by Happy Camel

Hello,

I'm looking at this project and it's almost perfect for my needs! One thing it's missing for me is a way to get a count of the number of socket connections that have been made to the mock webserver since it was started.

It's a long story, but the reason I need this is that I have implemented an HTTP 1.1 client that needs to act as if HTTP keep alive has been disabled. I need to make sure that every request uses a new socket rather than reusing connections, so the only way I can think to verify this is happening would be to use your project and then be able to compare the number of requests I have made to the server vs how many connections the server has seen. Does that make sense?

I would think about submitting a patch myself but it looks like it would maybe take quite a bit of refactoring to make that work...

Comment #1

Posted on Jul 31, 2012 by Massive Bear

Apologies for the slow reply.

The easiest solution to this is to look at the recorded request's sequence number. The sequence number will be 0 if it is the first request made on a socket connection, 1 if it's the 2nd request, and so on. If your keep-alive is disabled then all recorded requests will have sequence number 0.

Status: Done

Labels:
Type-Defect Priority-Medium