Saturday, October 26, 2013

API Designers: Please avoid magic

Just ran into this issue when using the tornado python module as a transparent proxy.  It seems that when you call set_status on the HTTPRequest object it tries to map that response code the a default "reason."  If there isn't a default value it throws an exception.

This is NOT the right thing to do because it creates a ticking time bomb.  I find this out after my server is running for 12 hours and the remote server responded with a 599 status code, causing my server to go into a weird state.

My preference would have been to either have this done explicitly, like setDefaultResponse, or, if a default wasn't found in the dictionary it would go to some pre-canned response.

No comments: