summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--response.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/response.c b/response.c
index 10cc941..abd4054 100644
--- a/response.c
+++ b/response.c
@@ -91,7 +91,26 @@ gboolean cbClientInput(gpointer data, gpointer additional)
//write output to client
static gssize writeOutput(GPollableOutputStream* stream, gchar* data)
{
- return g_pollable_output_stream_write_nonblocking(stream, data, strlen(data), NULL, NULL);
+ gssize written_bytes = 0;
+
+ gchar *terminated;
+ if(data==NULL) {
+ terminated = g_strdup("\r\n");
+ } else {
+ terminated = g_strdup_printf ("%s\r\n", data);
+ }
+
+// if(!strlen(out)) {
+// strcpy(out, " ");
+// }
+//
+// if(out[strlen(out)-1] != '\n' && out[strlen(out)-1] != '\r') {
+// strcat(out, "\n");
+// }
+
+ written_bytes = g_pollable_output_stream_write_nonblocking(stream, terminated, strlen(data), NULL, NULL);
+ g_free (terminated);
+ return written_bytes;
}
//initialize the signals
@@ -128,15 +147,6 @@ void responseCb(gpointer instance, GObject *arg1, gpointer user_data)
// FIXME - Parser_main may generate multiple responses
Parser_main(str, &out, 1);
- if(out==NULL) out=g_strdup(" ");
-
- if(!strlen(out)) {
- strcpy(out, " ");
- }
-
- if(out[strlen(out)-1] != '\n' && out[strlen(out)-1] != '\r') {
- strcat(out, "\n");
- }
written = data->cb(stream, out);
if (written == -1) {