Ignore:
Timestamp:
05/13/11 01:11:34 (9 years ago)
Author:
Admin
Message:

WebIf: Implement keepalive mechanism. This should make WebIf a lot more responsive as no new connection has to be created on each request (on SSL, the whole handshake process is also saved). Tested to work properly on Opera 11.10, Firefox 3.6.17 and IE9. Please report in the FORUM if you experience problems with this. In the meantime, you can restore old behaviour by removing the line "keepalive = 1" (line 3366) from oscam-http.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oscam-http-helpers.c

    r5226 r5229  
    502502        }
    503503    }
    504     pos += snprintf(pos, sizeof(buf)-(pos-buf), "Connection: close\r\n");
     504    if(*(int8_t *)pthread_getspecific(getkeepalive))
     505        pos += snprintf(pos, sizeof(buf)-(pos-buf), "Connection: Keep-Alive\r\n");
     506    else
     507        pos += snprintf(pos, sizeof(buf)-(pos-buf), "Connection: close\r\n");
    505508    pos += snprintf(pos, sizeof(buf)-(pos-buf),"\r\n");
    506509    if(forcePlain == 1) fwrite(buf, 1, strlen(buf), f);
     
    581584        send_header304(f);
    582585    } else {
    583         send_headers(f, 200, "OK", NULL, mimetype, 1, size, result, 0);
    584         webif_write(result, f);
     586        // We need at least size 1 or keepalive gets problems on some browsers...
     587        if(size < 1){
     588            send_headers(f, 200, "OK", NULL, mimetype, 1, 1, result, 0);
     589            webif_write(" ", f);
     590        } else {
     591            send_headers(f, 200, "OK", NULL, mimetype, 1, size, result, 0);
     592            webif_write(result, f);
     593        }
    585594    }
    586595    if(allocated) free(result);
Note: See TracChangeset for help on using the changeset viewer.