I have delphi code that basically uploads files to a remote secure server using Indy 10.4.704 :
IdHTTP := TIdHTTP.Create(nil);
try
TheCompressor := TIdCompressorZLib.Create(nil);
TheSSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
with IdHTTP do
begin
HTTPOptions := [hoForceEncodeParams];
AllowCookies := True;
HandleRedirects := True;
ProtocolVersion := pv1_1;
IOHandler := TheSSL;
Compressor := TheCompressor;
end;
try
IdHttp.Head('https://www.domain.com/my-file.bin');
if (IdHttp.Response.ResponseCode <> 404) And (IdHttp.Response.ContentLength >= 0) then
StartPos := IdHttp.Response.ContentLength
else
StartPos := 0;
except
StartPos := 0;
end;
TheFile := TFileStream.Create(FileName, fmOpenRead OR fmShareDenyWrite);
RangeStream := TIdHTTPRangeStream.Create(TheFile, StartPos, -1, True);
try
if (RangeStream.ResponseCode = 206) then
IdHTTP.Post(https:
finally
RangeStream.Free;
end;
finally
FreeAndNil(IdHTTP);
end;
The problem is that the code sometimes doesn't work when Indy throws an EIdSocketError Socket Error # 0 ( idHTTP.ResponseCode is -1)
Given my crappy internet connection, I ran an instance of Windows EC2 and tested it on it (the instance of Windows is running in the cloud, so I assume the connection is not a problem), but I have the same problem!
, , , , . TidLogFile, , , - :
Stat Connected.
Sent 4/26/2012 4:18:42: POST /app/upload.php...
Sent 4/26/2012 4:18:42: <uploaded_file_data_here>
Stat Disconnected.
- , / ?
I TIdSSLIOHandlerSocketOpenSSL. googled, , SSL.