Performance improvements. Removed the following deprecated functions from Socket::Connection class: flush(), Send(*)

This commit is contained in:
Thulinma 2014-09-24 16:31:56 +02:00
parent d0f2f78517
commit d442b4e2dc
5 changed files with 23 additions and 93 deletions

View file

@ -545,19 +545,24 @@ void HTTP::Parser::Chunkify(std::string & bodypart, Socket::Connection & conn) {
/// \param size The size of the data to send.
/// \param conn The connection to use for sending.
void HTTP::Parser::Chunkify(const char * data, unsigned int size, Socket::Connection & conn) {
static char hexa[] = "0123456789abcdef";
if (protocol == "HTTP/1.1") {
char len[10];
int sizelen = snprintf(len, 10, "%x\r\n", size);
//prepend the chunk size and \r\n
conn.SendNow(len, sizelen);
if (!size){
conn.SendNow("0\r\n\r\n\r\n", 7);
}
size_t offset = 8;
unsigned int t_size = size;
char len[] = "\000\000\000\000\000\000\0000\r\n";
while (t_size && offset < 9){
len[--offset] = hexa[t_size & 0xf];
t_size >>= 4;
}
conn.SendNow(len+offset, 10-offset);
//send the chunk itself
conn.SendNow(data, size);
//append \r\n
conn.SendNow("\r\n", 2);
if (!size) {
//append \r\n again if this was the end of the file (required by chunked transfer encoding according to spec)
conn.SendNow("\r\n", 2);
}
} else {
//just send the chunk itself
conn.SendNow(data, size);