Created
August 5, 2015 17:28
-
-
Save anonymous/22a493d83f5889066e11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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