[haiku-commits] haiku: hrev48611 - src/kits/network/libnetapi

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 5 Jan 2015 16:23:35 +0100 (CET)

hrev48611 adds 1 changeset to branch 'master'
old head: b5832c1759ea79952d7b7a451047387446995a31
new head: 71c761d99bdc590d853f7a246d14247493008a0e
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=71c761d+%5Eb5832c1

----------------------------------------------------------------------------

71c761d: 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.

                                 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev48611
Commit:      71c761d99bdc590d853f7a246d14247493008a0e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=71c761d
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Mon Jan  5 15:22:55 2015 UTC

Ticket:      https://dev.haiku-os.org/ticket/11687

----------------------------------------------------------------------------

1 file changed, 7 insertions(+), 1 deletion(-)
src/kits/network/libnetapi/HttpRequest.cpp | 8 +++++++-

----------------------------------------------------------------------------

diff --git a/src/kits/network/libnetapi/HttpRequest.cpp 
b/src/kits/network/libnetapi/HttpRequest.cpp
index 0b3b242..3f2f64d 100644
--- a/src/kits/network/libnetapi/HttpRequest.cpp
+++ b/src/kits/network/libnetapi/HttpRequest.cpp
@@ -98,7 +98,7 @@ BHttpRequest::BHttpRequest(const BHttpRequest& other)
        fOptHeaders(NULL),
        fOptPostFields(NULL),
        fOptInputData(NULL),
-       fOptInputDataSize(0),
+       fOptInputDataSize(-1),
        fOptRangeStart(other.fOptRangeStart),
        fOptRangeEnd(other.fOptRangeEnd),
        fOptFollowLocation(other.fOptFollowLocation)
@@ -1000,6 +1000,12 @@ BHttpRequest::_SendPostData()
        } else if ((fRequestMethod == B_HTTP_POST || fRequestMethod == 
B_HTTP_PUT)
                && 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 (;;) {
                        char outputTempBuffer[kHttpBufferSize];
                        ssize_t read = fOptInputData->Read(outputTempBuffer,


Other related posts: