Пример #1
0
void serverResponseWrite(JsVar *httpServerResponseVar, JsVar *data) {
    // Append data to sendData
    JsVar *sendData = jsvObjectGetChild(httpServerResponseVar, HTTP_NAME_SEND_DATA, 0);
    if (!sendData) {
        // There was no sent data, which means we haven't written headers yet.
        // Do that now with default values
        serverResponseWriteHead(httpServerResponseVar, 200, 0);
        // sendData should now have been set
        sendData = jsvObjectGetChild(httpServerResponseVar, HTTP_NAME_SEND_DATA, 0);
    }
    // check, just in case!
    if (sendData && !jsvIsUndefined(data)) {
        JsVar *s = jsvAsString(data, false);
        if (s) jsvAppendStringVarComplete(sendData,s);
        jsvUnLock(s);
    }
    jsvUnLock(sendData);
}
Пример #2
0
/*JSON{
  "type" : "method",
  "class" : "httpSRs",
  "name" : "writeHead",
  "generate" : "jswrap_httpSRs_writeHead",
  "params" : [
    ["statusCode","int32","The HTTP status code"],
    ["headers","JsVar","An object containing the headers"]
  ]
}*/
void jswrap_httpSRs_writeHead(JsVar *parent, int statusCode, JsVar *headers) {
  serverResponseWriteHead(parent, statusCode, headers);
}