mirror of
git://git.psyc.eu/libpsyc
synced 2024-08-15 03:19:02 +00:00
render: no \n after routing headers if content is empty
This commit is contained in:
parent
9f00ddcb1e
commit
a4e3dcc515
2 changed files with 10 additions and 4 deletions
|
@ -146,9 +146,14 @@ inline size_t psyc_setPacketLength(psycPacket *p)
|
|||
p->contentLength += p->data.length + 1; // data\n
|
||||
|
||||
// set total length: routing-header \n content |\n
|
||||
p->length = p->routingLength + 1 + p->contentLength + sizeof(PSYC_PACKET_DELIMITER) - 2;
|
||||
p->length = p->routingLength + p->contentLength + sizeof(PSYC_PACKET_DELIMITER) - 2;
|
||||
if (p->contentLength > 0)
|
||||
{
|
||||
p->contentLength--; // subtract the \n from the delimiter, as that doesn't belong to the content part
|
||||
p->length++; // add \n at the start of the content part
|
||||
if (p->flag == PSYC_PACKET_NEED_LENGTH) // add length of length if needed
|
||||
p->length += log10((double)p->data.length) + 1;
|
||||
}
|
||||
|
||||
return p->length;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,8 @@ psycRenderRC psyc_render(psycPacket *packet, char *buffer, size_t buflen)
|
|||
cur += itoa(packet->contentLength, buffer + cur, 10);
|
||||
}
|
||||
|
||||
buffer[cur++] = '\n'; // start of content part
|
||||
if (packet->entity.lines || packet->method.length || packet->data.length)
|
||||
buffer[cur++] = '\n'; // start of content part if there's content
|
||||
|
||||
// render entity modifiers
|
||||
for (i = 0; i < packet->entity.lines; i++)
|
||||
|
|
Loading…
Reference in a new issue