static void fts_tika_parser_response(const struct http_response *response, struct tika_fts_parser *parser) { i_assert(parser->payload == NULL); switch (response->status) { case 200: /* read response */ if (response->payload == NULL) parser->payload = i_stream_create_from_data("", 0); else { i_stream_ref(response->payload); parser->payload = response->payload; } break; case 204: /* empty response */ case 415: /* Unsupported Media Type */ case 422: /* Unprocessable Entity */ if (parser->user->mail_debug) { i_debug("fts_tika: PUT %s failed: %u %s", mail_user_plugin_getenv(parser->user, "fts_tika"), response->status, response->reason); } parser->payload = i_stream_create_from_data("", 0); break; case 500: /* Server Error - the problem could be anything (in Tika or HTTP server or proxy) and might be retriable, but Tika has trouble processing some documents and throws up this error every time for those documents. So we try retrying this a couple of times, but if that doesn't work we'll just ignore it. */ if (http_client_request_try_retry(parser->http_req)) return; i_info("fts_tika: PUT %s failed: %u %s - ignoring", mail_user_plugin_getenv(parser->user, "fts_tika"), response->status, response->reason); parser->payload = i_stream_create_from_data("", 0); break; default: i_error("fts_tika: PUT %s failed: %u %s", mail_user_plugin_getenv(parser->user, "fts_tika"), response->status, response->reason); parser->failed = TRUE; break; } parser->http_req = NULL; io_loop_stop(current_ioloop); }
void http_client_request_retry(struct http_client_request *req, unsigned int status, const char *error) { if (!http_client_request_try_retry(req)) http_client_request_error(&req, status, error); }