chansen/p5-http-tiny — pull request #37 by mjegh (2014-02-17 11:07:18+00:00)
Title: Avoid multiple writes when sending request

This change doesn't make any real difference to HTTP::Tiny unless you use keep_alive=1. If you do use keep_alive = 1, then because the socket is kept open when write_request_header() issues 2 small writes it is subject to the nagle algorithm. A simple benchmark GETting 2000 small files can increase from 5s to 79s.

An alternative is to set TCP_NODELAY but this might have other implications so combining the writes is the easiest and probably best solution.

See http://www.martin-evans.me.uk/node/169 for discussion of how I came across this.