summaryrefslogtreecommitdiff
path: root/response.c
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-13 18:03:43 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-13 18:03:43 -0400
commit17f1a001386bf5072009556757c05b2c952c92e1 (patch)
treed5146857393dc2a20b41c60600059dc75e54b4bc /response.c
parent92d5506d7fe5036999cca50d6b9b9cce3f29daff (diff)
always append CR+LF to outgoing message
Diffstat (limited to 'response.c')
-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) {