fts-parser-tika.c revision f74dbd3ff682fea040f60383e001620d1f1b09d3
/* Copyright (c) 2014-2016 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "istream.h"
#include "module-context.h"
#include "http-url.h"
#include "http-client.h"
#include "message-parser.h"
#include "mail-user.h"
#include "fts-parser.h"
#define TIKA_USER_CONTEXT(obj) \
struct fts_parser_tika_user {
};
struct tika_fts_parser {
struct fts_parser parser;
struct http_client_request *http_req;
bool failed;
};
static int
{
struct http_client_settings http_set;
/* fts_tika disabled */
return -1;
}
}
return -1;
}
if (tika_http_client == NULL) {
}
return 0;
}
static void
struct tika_fts_parser *parser)
{
case 200:
/* read response */
else {
}
break;
case 204: /* empty response */
case 415: /* Unsupported Media Type */
case 422: /* Unprocessable Entity */
i_debug("fts_tika: PUT %s failed: %u %s",
}
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.
Unfortunately we can't easily re-send the request here,
because we would have to re-send the entire payload, which
isn't available anymore here. So we'd need to indicate
in fts_parser_deinit() that we want to retry.
FIXME: do this in v2.3. For now we'll just ignore it. */
i_info("fts_tika: PUT %s failed: %u %s - ignoring",
break;
default:
i_error("fts_tika: PUT %s failed: %u %s",
break;
}
}
static struct fts_parser *
const char *content_disposition)
{
struct tika_fts_parser *parser;
struct http_client_request *http_req;
return NULL;
}
struct message_block *block)
{
const unsigned char *data;
/* first we'll send everything to Tika */
return;
}
/* read the result from Tika */
return;
}
/* continue returning data from Tika. we'll create a new ioloop just
for reading this one payload. */
break;
/* wait for more input from Tika */
} else {
}
}
/* switch back to original ioloop. */
;
else if (size > 0) {
} else {
/* finished */
i_error("read(%s) failed: %s",
}
}
}
{
/* remove io before unrefing payload - otherwise lib-http adds another
timeout to ioloop unnecessarily */
}
return ret;
}
static void fts_parser_tika_unload(void)
{
if (tika_http_client != NULL)
}
struct fts_parser_vfuncs fts_parser_tika = {
};