Fossil SCM
Simplify parsing of the Connection: header in HTTP replies.
Commit
77f25829d2f9f7b9877c6f35c16b8f7c445a94eb89009e01f78b4cf006de36eb
Parent
6173fbf526812c9…
1 file changed
+5
-17
+5
-17
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -569,27 +569,15 @@ | ||
| 569 | 569 | closeConnection = 0; |
| 570 | 570 | }else if( fossil_strnicmp(zLine, "content-length:", 15)==0 ){ |
| 571 | 571 | for(i=15; fossil_isspace(zLine[i]); i++){} |
| 572 | 572 | iLength = atoi(&zLine[i]); |
| 573 | 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] ); | |
| 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 | + } | |
| 591 | 579 | }else if( ( rc==301 || rc==302 || rc==307 || rc==308 ) && |
| 592 | 580 | fossil_strnicmp(zLine, "location:", 9)==0 ){ |
| 593 | 581 | int i, j; |
| 594 | 582 | int wasHttps; |
| 595 | 583 | |
| 596 | 584 |
| --- 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 |