50 lines
983 B
C++
50 lines
983 B
C++
#include <string.h>
|
|
|
|
#include <a8/a8.h>
|
|
|
|
#include <f8/f8.h>
|
|
#include <a8/mutable_xobject.h>
|
|
|
|
namespace f8
|
|
{
|
|
JsonHttpRequest::JsonHttpRequest()
|
|
{
|
|
resp_xobj = a8::MutableXObject::NewObject();
|
|
}
|
|
|
|
JsonHttpRequest::~JsonHttpRequest()
|
|
{
|
|
delete resp_xobj;
|
|
if (context && free_context) {
|
|
free_context(context);
|
|
}
|
|
}
|
|
|
|
std::string JsonHttpRequest::Response()
|
|
{
|
|
std::string response;
|
|
resp_xobj->ToJsonStr(response);
|
|
return a8::HttpResponse(response);
|
|
}
|
|
|
|
MsgHdr* MsgHdr::Clone()
|
|
{
|
|
MsgHdr* hdr = (MsgHdr*)malloc(sizeof(MsgHdr));
|
|
*hdr = *this;
|
|
if (hdr->buflen > 0) {
|
|
hdr->buf = (char*)malloc(hdr->buflen);
|
|
memmove((void*)hdr->buf, (void*)buf, buflen);
|
|
}
|
|
return hdr;
|
|
}
|
|
|
|
void MsgHdr::Destroy(MsgHdr* hdr)
|
|
{
|
|
if (hdr->buf) {
|
|
free((void*)hdr->buf);
|
|
}
|
|
free((void*)hdr);
|
|
}
|
|
|
|
}
|