Browse Source

[ci fw-only C/octane] Attempt to fix JSON test implementation (#4653)

* Attemp to make C/Octane JSON implementation compliant

* Use (const char *) type

* Remove some tabs and replace them with spaces.
Radoslav Petrov 6 years ago
parent
commit
6256efa4ba
1 changed files with 8 additions and 1 deletions
  1. 8 1
      frameworks/C/octane/src/responders/sds_responder.cpp

+ 8 - 1
frameworks/C/octane/src/responders/sds_responder.cpp

@@ -25,11 +25,18 @@ void create_plaintext_response_sds(write_batch* batch) {
 }
 }
 
 
 void create_json_response_sds(write_batch* batch) {
 void create_json_response_sds(write_batch* batch) {
+    // Taken from H20 implementation.
+    // volatile is used to ensure that the object is instantiated every time
+    // the function is called.
+    const volatile struct {
+        const char *message;
+    } object = {PLAINTEXT_CONTENT};
+
     StringBuffer s;
     StringBuffer s;
     Writer<StringBuffer> writer(s);
     Writer<StringBuffer> writer(s);
     writer.StartObject();
     writer.StartObject();
     writer.Key("message");
     writer.Key("message");
-    writer.String("Hello, World!");
+    writer.String((const char *)object.message, strlen(object.message));
     writer.EndObject();
     writer.EndObject();
 
 
     sds response_buffer = sdsnew("HTTP/1.1 200 OK\r\n");
     sds response_buffer = sdsnew("HTTP/1.1 200 OK\r\n");