diff options
Diffstat (limited to 'bdep/http-service.hxx')
-rw-r--r-- | bdep/http-service.hxx | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/bdep/http-service.hxx b/bdep/http-service.hxx new file mode 100644 index 0000000..b1db7e7 --- /dev/null +++ b/bdep/http-service.hxx @@ -0,0 +1,59 @@ +// file : bdep/http-service.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2018 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#ifndef BDEP_HTTP_SERVICE_HXX +#define BDEP_HTTP_SERVICE_HXX + +#include <libbutl/manifest-parser.mxx> + +#include <bdep/types.hxx> +#include <bdep/utility.hxx> + +#include <bdep/common-options.hxx> + +namespace bdep +{ + namespace http_service + { + // If type is file, then the value is a path to be uploaded. + // + struct parameter + { + enum {text, file} type; + string name; + string value; + }; + using parameters = vector<parameter>; + + struct result + { + string message; + optional<string> reference; + + // Does not include status, message, or reference. + // + vector<butl::manifest_name_value> body; + }; + + // Submit text parameters and/or upload files to an HTTP service via the + // POST method. Use the multipart/form-data content type if any files are + // uploaded and application/x-www-form-urlencoded otherwise. + // + // On success, return the response manifest message and reference (if + // present, see below) and the rest of the manifest values, if any. Issue + // diagnostics and fail if anything goes wrong or the response manifest + // status value is not 200 (success). + // + // Note that the HTTP service is expected to respond with the result + // manifest that starts with the 'status' (HTTP status code) and 'message' + // (diagnostics message) values optionally followed by 'reference' and + // then other manifest values. If the status is not 200 and reference is + // present, then it is included in the diagnostics. + // + result + post (const common_options& o, const url&, const parameters&); + } +} + +#endif // BDEP_HTTP_SERVICE_HXX |