Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix downloading tiny files (less than 100 bytes) #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions SRC/NETWORK/hget.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* HTTP getter 1.3
/* HTTP getter 1.3.1
By Konamiman 1/2011 v1.1
By Oduvaldo Pavan Junior 07/2019 v1.3

Expand Down Expand Up @@ -102,6 +102,8 @@ typedef unsigned char bool;

#define MAX_REDIRECTIONS 10

#define PROGRESS_BAR_SIZE 25

enum TcpipUnapiFunctions {
UNAPI_GET_INFO = 0,
TCPIP_GET_CAPAB = 1,
Expand Down Expand Up @@ -141,7 +143,7 @@ enum TcpipErrorCodes {
#define strDefaultFilename "index.htm";

const char* strTitle=
"HTTP file downloader 1.3\r\n"
"HTTP file downloader 1.3.1\r\n"
"By Oduvaldo ([email protected]) 7/2019\r\n"
"Based on HGET 1.1 by Konamiman\r\n"
"\r\n";
Expand Down Expand Up @@ -224,6 +226,7 @@ int remainingInputData = 0;
byte* inputDataPointer;
int emptyLineReaded;
long contentLength,blockSize,currentBlock;
byte printedProgressBar;
bool isFirstUpdate;
int isChunkedTransfer;
long currentChunkSize = 0;
Expand Down Expand Up @@ -1422,7 +1425,8 @@ void DoDirectDatatransfer()
print(" ");
if (contentLength)
{
blockSize = contentLength/25;
printedProgressBar = 0;
blockSize = contentLength/PROGRESS_BAR_SIZE;
currentBlock = 0;
isFirstUpdate = true;
}
Expand All @@ -1445,7 +1449,7 @@ void DoChunkedDataTransfer()
print(" ");
if (contentLength)
{
blockSize = contentLength/25;
blockSize = contentLength/PROGRESS_BAR_SIZE;
currentBlock = 0;
isFirstUpdate = true;
}
Expand Down Expand Up @@ -1573,11 +1577,16 @@ void UpdateReceivingMessage()
isFirstUpdate=false;
print("\r[ ]\r\x1c");
}
while (currentBlock>=blockSize)
if (!blockSize) {
currentBlock = PROGRESS_BAR_SIZE;
blockSize = 1;
}
while (printedProgressBar < PROGRESS_BAR_SIZE && currentBlock>=blockSize)
{
printedProgressBar++;
currentBlock-=blockSize;
print("=");
}
}
}
else
{
Expand Down