- Getting Started
- Installation
- Key Concepts
- Integrations
- Account & Billing
- Security & Privacy
- PDF Generation
- Reference
- Tutorials
- Troubleshooting
- Excel Generation
- Reference
- Troubleshooting
[2012-09-25] Added HTTP Timeout API Parameter
Most DocRaptor customers have complete control over the assets they use in their assets, but one of our newer customers is aggregating content from a variety of marketing material. All of the assets from that material may or may not be available. Bloomingdale’s is not going to keep their May, 2012 email marketing content online forever.
Enter http_timeout
, the latest feature available for DocRaptor. By default, we try to fetch an external resource for up to 60 seconds. With this option, you can set the timeout to whatever you want. As an example, here’s a contrived document that takes a long time due to timeout:
curl http:s//docraptor.com/docs \ --fail --silent --show-error \ --header "Content-Type:application/json" \ --data '{"user_credentials":"YOUR_API_KEY_HERE", "doc":{"name":"docraptor_sample.pdf", "document_type":"pdf", "test":"true", "document_content":"<html><body><img src='http://docraptor-callbacks.herokuapp.com/slow'></body></html>"}}' > docraptor_sample.pdf
If you run that command, it will sit there for quite a while waiting for a timeout. Let’s try setting the timeout to 5 seconds:
curl https://docraptor.com/docs \ --fail --silent --show-error \ --header "Content-Type:application/json" \ --data '{"user_credentials":"YOUR_API_KEY_HERE", "doc":{"name":"docraptor_sample.pdf", "prince_options":{"http_timeout":"5", "version":"8.1"}, "document_type":"pdf", "test":"true", "document_content":"<html><body><img src='http://docraptor-callbacks.herokuapp.com/slow'></body></html>"}}' > docraptor_sample.pdf
Much better.
The important part is:
"prince_options":{"http_timeout":"5", "version":"8.1"}
This option only works if you’re Prince 8 (or newer). If you’re using an older version, the option is ignored. It’s not necessary to specify the Prince version if you’re already using 8.1 as your default. If you’re not sure, check your profile page. It’s easy to switch!