To answer my own question (and maybe help someone else), it turns out
my web server was sending chunked responses and inserting chunk sizes
before each data chunk.
Changing the line:
request<-paste("POST ",path," HTTP/1.1\nHost: ",host...
to
request<-paste("POST ",path," HTTP/1.0\nHost: ",host...
disables chunked reponses and allows R to read directly from the socket
without additional parsing. So this wasn't really an R problem, but I
thought this detail might help someone else.
--
Mike