Fossil SCM

If the reply to an HTTP request omits the content-length, assume that the server wants us to close the connection. [forum:/forumpost/815e4320c8|Forum post 815e4320c8].

drh 2026-01-09 16:41 trunk
Commit aa7a08772613605bbcd68c81d40a7886d464cf2a33ccae153a16d1434b46b003
1 file changed +2 -6
+2 -6
--- src/http.c
+++ src/http.c
@@ -751,15 +751,16 @@
751751
if( mHttpFlags & HTTP_QUIET ) goto write_err;
752752
fossil_warning("response truncated: got %d bytes of %d",
753753
iRecvLen, iLength);
754754
goto write_err;
755755
}
756
- }else if( closeConnection ){
756
+ }else{
757757
/* Read content until end-of-file */
758758
int iRecvLen; /* Received length of the reply payload */
759759
unsigned int nReq = 1000;
760760
unsigned int nPrior = 0;
761
+ closeConnection = 1;
761762
do{
762763
nReq *= 2;
763764
blob_resize(pReply, nPrior+nReq);
764765
iRecvLen = transport_receive(&g.url, &pReply->aData[nPrior], (int)nReq);
765766
nPrior += iRecvLen;
@@ -766,15 +767,10 @@
766767
pReply->nUsed = nPrior;
767768
}while( iRecvLen==nReq && nReq<0x20000000 );
768769
if( mHttpFlags & HTTP_VERBOSE ){
769770
fossil_print("Reply received: %u bytes (w/o content-length)\n", nPrior);
770771
}
771
- }else{
772
- assert( iLength<0 && !closeConnection );
773
- if( mHttpFlags & HTTP_QUIET ) goto write_err;
774
- fossil_warning("\"content-length\" missing from %d keep-alive reply", rc);
775
- goto write_err;
776772
}
777773
if( isError ){
778774
char *z;
779775
int i, j;
780776
z = blob_str(pReply);
781777
--- src/http.c
+++ src/http.c
@@ -751,15 +751,16 @@
751 if( mHttpFlags & HTTP_QUIET ) goto write_err;
752 fossil_warning("response truncated: got %d bytes of %d",
753 iRecvLen, iLength);
754 goto write_err;
755 }
756 }else if( closeConnection ){
757 /* Read content until end-of-file */
758 int iRecvLen; /* Received length of the reply payload */
759 unsigned int nReq = 1000;
760 unsigned int nPrior = 0;
 
761 do{
762 nReq *= 2;
763 blob_resize(pReply, nPrior+nReq);
764 iRecvLen = transport_receive(&g.url, &pReply->aData[nPrior], (int)nReq);
765 nPrior += iRecvLen;
@@ -766,15 +767,10 @@
766 pReply->nUsed = nPrior;
767 }while( iRecvLen==nReq && nReq<0x20000000 );
768 if( mHttpFlags & HTTP_VERBOSE ){
769 fossil_print("Reply received: %u bytes (w/o content-length)\n", nPrior);
770 }
771 }else{
772 assert( iLength<0 && !closeConnection );
773 if( mHttpFlags & HTTP_QUIET ) goto write_err;
774 fossil_warning("\"content-length\" missing from %d keep-alive reply", rc);
775 goto write_err;
776 }
777 if( isError ){
778 char *z;
779 int i, j;
780 z = blob_str(pReply);
781
--- src/http.c
+++ src/http.c
@@ -751,15 +751,16 @@
751 if( mHttpFlags & HTTP_QUIET ) goto write_err;
752 fossil_warning("response truncated: got %d bytes of %d",
753 iRecvLen, iLength);
754 goto write_err;
755 }
756 }else{
757 /* Read content until end-of-file */
758 int iRecvLen; /* Received length of the reply payload */
759 unsigned int nReq = 1000;
760 unsigned int nPrior = 0;
761 closeConnection = 1;
762 do{
763 nReq *= 2;
764 blob_resize(pReply, nPrior+nReq);
765 iRecvLen = transport_receive(&g.url, &pReply->aData[nPrior], (int)nReq);
766 nPrior += iRecvLen;
@@ -766,15 +767,10 @@
767 pReply->nUsed = nPrior;
768 }while( iRecvLen==nReq && nReq<0x20000000 );
769 if( mHttpFlags & HTTP_VERBOSE ){
770 fossil_print("Reply received: %u bytes (w/o content-length)\n", nPrior);
771 }
 
 
 
 
 
772 }
773 if( isError ){
774 char *z;
775 int i, j;
776 z = blob_str(pReply);
777

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button