HttpRequest: rewind the input data before sending it
* This is needed for redirects to work as expected. * It makes it harder to send data starting from the middle of a BPositionIO (you now need a wrapper object), but that is an uncommon feature so it is acceptable. Fixes #11687.
This commit is contained in:
@@ -98,7 +98,7 @@ BHttpRequest::BHttpRequest(const BHttpRequest& other)
|
|||||||
fOptHeaders(NULL),
|
fOptHeaders(NULL),
|
||||||
fOptPostFields(NULL),
|
fOptPostFields(NULL),
|
||||||
fOptInputData(NULL),
|
fOptInputData(NULL),
|
||||||
fOptInputDataSize(0),
|
fOptInputDataSize(-1),
|
||||||
fOptRangeStart(other.fOptRangeStart),
|
fOptRangeStart(other.fOptRangeStart),
|
||||||
fOptRangeEnd(other.fOptRangeEnd),
|
fOptRangeEnd(other.fOptRangeEnd),
|
||||||
fOptFollowLocation(other.fOptFollowLocation)
|
fOptFollowLocation(other.fOptFollowLocation)
|
||||||
@@ -1000,6 +1000,12 @@ BHttpRequest::_SendPostData()
|
|||||||
} else if ((fRequestMethod == B_HTTP_POST || fRequestMethod == B_HTTP_PUT)
|
} else if ((fRequestMethod == B_HTTP_POST || fRequestMethod == B_HTTP_PUT)
|
||||||
&& fOptInputData != NULL) {
|
&& fOptInputData != NULL) {
|
||||||
|
|
||||||
|
// If the input data is seekable, we rewind it for each new request.
|
||||||
|
BPositionIO* seekableData
|
||||||
|
= dynamic_cast<BPositionIO*>(fOptInputData);
|
||||||
|
if (seekableData)
|
||||||
|
seekableData->Seek(0, SEEK_SET);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char outputTempBuffer[kHttpBufferSize];
|
char outputTempBuffer[kHttpBufferSize];
|
||||||
ssize_t read = fOptInputData->Read(outputTempBuffer,
|
ssize_t read = fOptInputData->Read(outputTempBuffer,
|
||||||
|
|||||||
Reference in New Issue
Block a user