Skip to content

Instantly share code, notes, and snippets.

Created August 5, 2015 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/22a493d83f5889066e11 to your computer and use it in GitHub Desktop.
Save anonymous/22a493d83f5889066e11 to your computer and use it in GitHub Desktop.
using namespace std;
requestHandle::requestHandle(request originalClient,response originalResponse){
client = originalClient;
clientResponse = originalResponse;
}
void requestHandle::header(string key,string value){
if (MHD_add_response_header (clientResponse.resp, key.c_str(), value.c_str()) == MHD_NO){
print("error while adding the headers");
}else{
print("headers have been added successfully");
}
}
void requestHandle::print(string printData){
clientResponse.data.append(printData);
}
void requestHandle::status(int status){
clientResponse.status_code = status;
}
int requestHandle::flush(){
clientResponse.resp = MHD_create_response_from_buffer(clientResponse.data.length(),
(void *)clientResponse.data.c_str(),MHD_RESPMEM_PERSISTENT);
int ret = MHD_queue_response(client.connection,clientResponse.status_code,clientResponse.resp);
MHD_destroy_response(clientResponse.resp);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment