Subject: | CODE ref in content has no way to reset if request repeats |
Consider a PUT or POST request with a CODE reference for its content. LWP sends the
request, but the response it gets is 401 Unauthorized. Fortunately, LWP has the credentials
needed, so it repeats the request, adding the needed credentials.
Here's the bug: the first request includes the body, but the second does not. I assume this is
because LWP simply calls the CODE reference again without making any attempt to "reset" it
(there is no mechanism for doing so).
Note that this bug would probably also occur if the server issued a redirect. (I haven't tested
this, of course.)
Possible solutions:
1. Document that this is the case, and that the sub should reset itself if it reaches the end-
of-data condition, in case the request is repeated.
2. Pass a byte number to the sub, and document that it should reset its state if the count is
zero.
3. Pass a reset flag to the sub, and document the meaning of the flag.
All in all, this seems to have happened because the feature is so underdocumented; it's only
ever mentioned in LWP::UserAgent. Perhaps the documentation of this feature overall should
be improved.