Ruby Net::HTTP vs Sketchup::Http

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.

All of it was done with the Ruby Net::HTTP library (2.5, 2.2) over ssl. I wrote the code using Ruby 2.7.0dev, but it works fine in SU 2018 with Ruby 2.2.4.

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.


  1. 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.

  2. Net:HTTP.start’s options parameter allows more control over the connection.

  3. Net:HTTP can be used in stand-alone Ruby, allowing one to write and test code there.


  1. 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

Here’s a discussion about this in the API issue tracker:

1 Like

The main issue is that the use of Net::HTTP blocks SketchUp. You might not notice if the server response is fast, but you will if things are slow. The SketchUp application can go into “Not Responding” mode.

Also if your extension needs to connect to a server when it loads, this can cause a noticeable delay in SketchUp’s loading and toolbar building.

The API block form methods are implemented to be non-blocking.

The above blocking situation is still true in all versions up through 2019, AFAIK.