[twsocket] [PATCH] HttpSrv: Fix in THttpRangeStream for incomplete reads

2012-08-21 Thread Tobias Rapp
Hi,

when using the HTTP server component with some custom TStream descendant
together with partial GET requests I noticed that the Read method of
THttpRangeStream incorrectly handles the situation where Read returns less
bytes that requested. It switches to the next stream member in the list
without checking if end-of-stream has been reached.

The included patch fixes this bug. It would be great if you could consider
including the patch in the upstream version of ICS.

Regards,
Tobias


(begin patch)

Index: OverbyteIcsHttpSrv.pas
===
--- OverbyteIcsHttpSrv.pas  (revision 1075)
+++ OverbyteIcsHttpSrv.pas  (working copy)
@@ -6236,9 +6236,12 @@
 ActSize   := min(Count - DataRead, Rec.Size - (ActOffset));
 Rec.Stream.Position := ActOffset + Rec.StartPos;
 SizeRead := Rec.Stream.Read(Pointer(DWORD(@Buffer) + 
DWORD(DataRead))^, ActSize);
-Inc(Index);
 Inc(DataRead, SizeRead);
 Inc(FPosition, SizeRead);
+if (Rec.Offset + Rec.Size)  FPosition then
+Break
+else
+Inc(Index);
 end;
 Result := DataRead;
 Exit;

(end patch)

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] [PATCH] HttpSrv: Fix in THttpRangeStream for incomplete reads

2012-08-21 Thread Angus Robertson - Magenta Systems Ltd
 The included patch fixes this bug. It would be great if you could 
 consider including the patch in the upstream version of ICS.

Thanks, the V8 repository will be updated this morning. 

Angus

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] [PATCH] HttpSrv: Fix in THttpRangeStream for incomplete reads

2012-08-21 Thread Tobias Rapp
Angus Robertson - Magenta Systems Ltd wrote:
 Thanks, the V8 repository will be updated this morning. 

Nice. Any chance the patch could also be applied to V7 (trunk)?

Regards,
Tobias


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] [PATCH] HttpSrv: Fix in THttpRangeStream for incomplete reads

2012-08-21 Thread Angus Robertson - Magenta Systems Ltd
  Thanks, the V8 repository will be updated this morning. 
 Nice. Any chance the patch could also be applied to V7 (trunk)?

OK, both V7 and V8 are updated with your fix, and the 'nightly' zips
updated early.  

I also added another web server fix that previously was only in V8. 

Angus

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] [PATCH] HttpSrv: Fix in THttpRangeStream for incomplete reads

2012-08-21 Thread Tobias Rapp
Angus Robertson - Magenta Systems Ltd wrote:
 OK, both V7 and V8 are updated with your fix, and the 'nightly' zips
 updated early.  
 
 I also added another web server fix that previously was only in V8. 

Great. 

Thanks,
Tobias

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be