Fossil SCM

Simplify parsing of the Connection: header in HTTP replies.

drh 2024-04-21 15:37 connection-http-header
Commit 77f25829d2f9f7b9877c6f35c16b8f7c445a94eb89009e01f78b4cf006de36eb
1 file changed +5 -17
+5 -17
--- src/http.c
+++ src/http.c
@@ -569,27 +569,15 @@
569569
closeConnection = 0;
570570
}else if( fossil_strnicmp(zLine, "content-length:", 15)==0 ){
571571
for(i=15; fossil_isspace(zLine[i]); i++){}
572572
iLength = atoi(&zLine[i]);
573573
}else if( fossil_strnicmp(zLine, "connection:", 11)==0 ){
574
- int j; /* Position of next separator (comma or zero terminator). */
575
- int k = 0; /* Position after last non-space char for current value. */
576
- i = 11;
577
- do{
578
- while( fossil_isspace(zLine[i]) || zLine[i]==',' ) i++;
579
- j = i;
580
- while( zLine[j] && zLine[j]!=',' ){
581
- if( !fossil_isspace(zLine[j]) ) k = j + 1;
582
- j++;
583
- }
584
- if( k-i==5 && fossil_strnicmp(&zLine[i], "close", 5)==0 ){
585
- closeConnection = 1;
586
- }else if( k-i==10 && fossil_strnicmp(&zLine[i], "keep-alive", 10)==0 ){
587
- closeConnection = 0;
588
- }
589
- i = j;
590
- }while( zLine[i] );
574
+ if( sqlite3_strlike("%close%", &zLine[11], 0)==0 ){
575
+ closeConnection = 1;
576
+ }else if( sqlite3_strlike("%keep-alive%", &zLine[11], 0)==0 ){
577
+ closeConnection = 0;
578
+ }
591579
}else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
592580
fossil_strnicmp(zLine, "location:", 9)==0 ){
593581
int i, j;
594582
int wasHttps;
595583
596584
--- src/http.c
+++ src/http.c
@@ -569,27 +569,15 @@
569 closeConnection = 0;
570 }else if( fossil_strnicmp(zLine, "content-length:", 15)==0 ){
571 for(i=15; fossil_isspace(zLine[i]); i++){}
572 iLength = atoi(&zLine[i]);
573 }else if( fossil_strnicmp(zLine, "connection:", 11)==0 ){
574 int j; /* Position of next separator (comma or zero terminator). */
575 int k = 0; /* Position after last non-space char for current value. */
576 i = 11;
577 do{
578 while( fossil_isspace(zLine[i]) || zLine[i]==',' ) i++;
579 j = i;
580 while( zLine[j] && zLine[j]!=',' ){
581 if( !fossil_isspace(zLine[j]) ) k = j + 1;
582 j++;
583 }
584 if( k-i==5 && fossil_strnicmp(&zLine[i], "close", 5)==0 ){
585 closeConnection = 1;
586 }else if( k-i==10 && fossil_strnicmp(&zLine[i], "keep-alive", 10)==0 ){
587 closeConnection = 0;
588 }
589 i = j;
590 }while( zLine[i] );
591 }else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
592 fossil_strnicmp(zLine, "location:", 9)==0 ){
593 int i, j;
594 int wasHttps;
595
596
--- src/http.c
+++ src/http.c
@@ -569,27 +569,15 @@
569 closeConnection = 0;
570 }else if( fossil_strnicmp(zLine, "content-length:", 15)==0 ){
571 for(i=15; fossil_isspace(zLine[i]); i++){}
572 iLength = atoi(&zLine[i]);
573 }else if( fossil_strnicmp(zLine, "connection:", 11)==0 ){
574 if( sqlite3_strlike("%close%", &zLine[11], 0)==0 ){
575 closeConnection = 1;
576 }else if( sqlite3_strlike("%keep-alive%", &zLine[11], 0)==0 ){
577 closeConnection = 0;
578 }
 
 
 
 
 
 
 
 
 
 
 
 
579 }else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) &&
580 fossil_strnicmp(zLine, "location:", 9)==0 ){
581 int i, j;
582 int wasHttps;
583
584

Keyboard Shortcuts

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