/** * HTTP client processing callback * * @param context Pointer to a HTTP easy context */ static void rinoohttp_easy_client_process(void *context) { int i; bool found; t_buffer body; t_rinoohttp http; t_rinoohttp_easy_context *econtext = context; rinoohttp_init(econtext->socket, &http); while (rinoohttp_request_get(&http)) { for (i = 0, found = false; i < econtext->nbroutes && found == false; i++) { if (econtext->routes[i].uri == NULL || buffer_strcmp(&http.request.uri, econtext->routes[i].uri) == 0 || (econtext->routes[i].type == RINOO_HTTP_ROUTE_DIR && buffer_strncmp(&http.request.uri, econtext->routes[i].uri, strlen(econtext->routes[i].uri)) == 0)) { rinoohttp_easy_route_call(&http, &econtext->routes[i]); found = true; } } if (found == false) { http.response.code = 404; strtobuffer(&body, RINOO_HTTP_ERROR_404); rinoohttp_response_send(&http, &body); } rinoohttp_reset(&http); } rinoohttp_destroy(&http); rinoo_socket_destroy(econtext->socket); free(econtext); }
void process_client(void *socket) { t_buffer *buffer; buffer = buffer_create(NULL); XTEST(buffer != NULL); while (rinoo_socket_readb(socket, buffer) > 0) { rinoo_log("receiving..."); } XTEST(buffer_size(buffer) == TRANSFER_SIZE); XTEST(buffer_strncmp(buffer, str, TRANSFER_SIZE) == 0); buffer_destroy(buffer); free(str); rinoo_socket_destroy(socket); }