summaryrefslogtreecommitdiff
path: root/spec/unit/network/http/factory_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-07-25(PUP-744) Remove private Connection#connection methodJosh Cooper1-0/+45
Previously, the `Connection#connection` method was used in `connection_spec.rb` to validate the state of the Net::HTTP object created by the puppet connection. Since the puppet connection no longer owns an Net::HTTP object (it may use newly created or cached instances), the `#connection` method doesn't make sense, and since it was private, can be removed. The tests that relied on the private method have been updated, and in some cases moved to the factory_spec, e.g. verifying proxy settings.
2014-07-25(PUP-744) Ensure connections we create support at least HTTP 1.1Josh Cooper1-0/+6
When starting a persistent HTTP connection, we do not expliclty specify `Connection: Keep-Alive`, because that is the default in HTTP/1.1[1]. This commit adds a test to ensure we are using HTTP 1.1 or later. Amazingly ruby has defaulted to 1.1 as far back as ruby 1.8.7[2]. [1] http://tools.ietf.org/html/rfc7230#appendix-A.1.2 [2] https://github.com/ruby/ruby/blob/v1_8_7/lib/net/http.rb#L282
2014-07-25(PUP-744) Move connection factory into the poolsJosh Cooper1-6/+3
Previously, the puppet connection class owned the Net::HTTP factory and passed it to the pool when requesting a connection. However, the caching pool only needs the factory when creating a new connection. This commit makes the factory stateless and pushes it into the respective pools. The SSL verifier is stateful (contains peer certs) and remains in puppet's connection class. When a pool needs to create a connection, it calls back into the puppet connection object to initialize SSL on the Net::HTTP object. In the case of the caching poool, it needs to do this before starting the connection, which will perform the TCP connect and SSL handshake operations.
2014-07-25(PUP-744) Refactor to use Net::HTTP factoryJosh Cooper1-0/+34
Previously, puppet connections were directly responsible for creating Net::HTTP objects. This was okay because there was only one code path where new Net::HTTP objects needed to be created. However, in order to support different connection pool behaviors, caching and non-caching of Net::HTTP objects, we want to have two pool implementations, and each of them will need the ability to create Net::HTTP objects. This commit creates a factory object for creating Net::HTTP objects, and has the puppet connection delegate to it.