I was recently writing some (stand-alone) Ruby code that hit several servers with REST/API HTTP calls. IOW, using http to retrieve data (json) from a server.
Back in the old days of SketchUp (SU), the Net::HTTP library had issues, and the SU team added Sketchup::Http as a replacement.
I think that if one is targeting SU versions with Ruby 2.2 or later, one should consider using Net::HTTP.
If one is doing multiple requests, and given that many connections are using ssl (https), using Net:HTTP.start allows one to negotiate a single ssl connection and perform multiple requests, assuming the conections are done in quick succession.
Net:HTTP.start’s options parameter allows more control over the connection.
Net:HTTP can be used in stand-alone Ruby, allowing one to write and test code there.
- Net:HTTP uses the OpenSSL library that Ruby is packaged with. OpenSSL 1.0.2 and earlier takes a second or two to intialize itself on the first connection. Subsequent connections are faster. This may not be an issue with Sketchup::Http.
To see what version of OpenSSL is used:
require 'openssl' ; puts OpenSSL::OPENSSL_LIBRARY_VERSION