aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/libmdsserver/mds-message.c9
-rwxr-xr-xtest.d/dumb-client2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/libmdsserver/mds-message.c b/src/libmdsserver/mds-message.c
index dcb8986..b324ad4 100644
--- a/src/libmdsserver/mds-message.c
+++ b/src/libmdsserver/mds-message.c
@@ -120,7 +120,7 @@ int mds_message_read(mds_message_t* restrict this, int fd)
char* header;
/* We have found an empty line, i.e. the end of the headers.*/
- if (len == 0)
+ if (len == 1)
{
/* Remove the \n (end of empty line) we found from the buffer. */
memmove(this->buffer, this->buffer + 1, this->buffer_ptr -= 1);
@@ -162,7 +162,7 @@ int mds_message_read(mds_message_t* restrict this, int fd)
if (header_commit_buffer == 0)
{
header_commit_buffer = 8;
- if (this->headers == NULL)
+ if (this->header_count == 0)
{
if (xmalloc(this->headers, header_commit_buffer, char*))
return -1;
@@ -211,6 +211,11 @@ int mds_message_read(mds_message_t* restrict this, int fd)
}
/* Stage 1: payload. */
+ if ((this->stage == 1) && (this->payload_ptr == 0))
+ {
+ this->stage = 2;
+ return 0;
+ }
if ((this->stage == 1) && (this->payload_ptr > 0))
{
/* How much of the payload that has not yet been filled. */
diff --git a/test.d/dumb-client b/test.d/dumb-client
index 4868813..0ee7331 100755
--- a/test.d/dumb-client
+++ b/test.d/dumb-client
@@ -50,7 +50,7 @@ thread.start()
while True:
try:
- data = input().encode('utf-8')
+ data = (input() + '\n').encode('utf-8')
except:
break
socket.send(data);