Skip to content

Commit

Permalink
default speed limit 50MBps
Browse files Browse the repository at this point in the history
  • Loading branch information
rejetto committed Aug 30, 2020
1 parent e233f6d commit 29f6bac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 5 additions & 4 deletions hslib.pas
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ThttpReply = record
);
body: ansistring; // specifies reply body according to bodyMode
bodyFile: string;
bodyStream: Tstream; // note: the stream is automatically freed
bodyStream: Tstream; // note: the stream is automatically freed
firstByte, lastByte: int64; // body interval for partial replies (206)
realm, // this will appear in the authentication dialog
reason, // customized reason phrase
Expand Down Expand Up @@ -423,7 +423,7 @@ function nonQuotedPos(ss, s:string; ofs:integer=1; quote:string='"'; unquote:str
repeat
result:=posEx(ss, s, ofs);
if result = 0 then exit;

repeat
qpos:=posEx(quote, s, ofs);
if qpos = 0 then exit; // there's no quoting, our result will fit
Expand Down Expand Up @@ -1599,7 +1599,7 @@ function ThttpConn.initInputStream():boolean;

function ThttpConn.sendNextChunk(max:integer=MAXINT):integer;
var
n: int64;
n, toSend: int64;
buf: ansistring;
begin
result:=0;
Expand All @@ -1611,7 +1611,8 @@ function ThttpConn.sendNextChunk(max:integer=MAXINT):integer;
if n > MAXIMUM_CHUNK_SIZE then n:=MAXIMUM_CHUNK_SIZE;
if n < MINIMUM_CHUNK_SIZE then n:=MINIMUM_CHUNK_SIZE;
if n > max then n:=max;
if n > bytesToSend then n:=bytesToSend;
toSend:=bytesToSend;
if n > toSend then n:=toSend;
if n = 0 then exit;
setLength(buf, n);
n:=stream.read(buf[1], n);
Expand Down
8 changes: 3 additions & 5 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5025,8 +5025,6 @@ procedure Tmainfrm.httpEvent(event:ThttpEvent; conn:ThttpConn);
nofolders, selection, itsAsearch: boolean;

procedure addToTar(src,dst:string);
var
i: integer;
begin
if not selection or not tar.contains(src) then
tar.addFile(src, dst);
Expand Down Expand Up @@ -8120,10 +8118,10 @@ procedure TmainFrm.timerEvent(Sender: TObject);

if userSocketBuffer > 0 then
data.conn.sndBuf:=userSocketBuffer
else
else if highSpeedChk.checked then
begin
size:=minmax(8192, MEGA, round(data.averageSpeed));
if highSpeedChk.checked and (safeDiv(0.0+size, data.conn.sndbuf, 2) > 2) then
if safeDiv(0.0+size, data.conn.sndbuf, 2) > 2 then
data.conn.sndBuf:=size;
end;
end;
Expand Down Expand Up @@ -12126,7 +12124,7 @@ function Tmainfrm.finalInit():boolean;
DragAcceptFiles(handle, true);
caption:=format('HFS ~ HTTP File Server %s', [VERSION]);
application.Title:=format('HFS %s', [VERSION]);
setSpeedLimit(-1);
setSpeedLimit(50000);
setSpeedLimitIP(-1);
setGraphRate(10);
setMaxConnections(0);
Expand Down

0 comments on commit 29f6bac

Please sign in to comment.