Microsoft Information Protection (MIP) SDK for C: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C
Loading...
Searching...
No Matches
http_delegate_cc.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27
28/**
29 * @brief Defines HTTP callback functions
30 *
31 * @file http_delegate_cc.h
32 */
33
34#ifndef API_MIP_HTTP_DELEGATE_CC_H_
35#define API_MIP_HTTP_DELEGATE_CC_H_
36
37#include <stddef.h>
38#include <stdint.h>
39
41#include "mip_cc/error_cc.h"
43#include "mip_cc/result_cc.h"
44
45/**
46 * @brief HTTP request type
47 */
48typedef enum {
49 HTTP_REQUEST_TYPE_GET = 0, /**< HTTP GET */
50 HTTP_REQUEST_TYPE_POST = 1, /**< HTTP POST */
52
53/**
54 * @brief Success/failure state of the HTTP operation
55 */
56typedef enum {
57 HTTP_RESULT_OK = 0, /**< HTTP operation was completed successfull */
58 HTTP_RESULT_FAILURE = 1, /**< HTTP operation failed (e.g. timeout, network failure, etc.) */
60
61/**
62 * @brief HTTP request/response header
63 */
64typedef struct {
65 const char* name; /**< Header name/key */
66 const char* value; /**< Header value */
68
69/**
70 * @brief HTTP request
71 */
72typedef struct {
73 const char* id; /**< Unique request ID--correlated with the same property in mip_cc_http_response */
74 mip_cc_http_request_type type; /**< HTTP request type (e.g. GET vs. POST) */
75 const char* url; /**< HTTP request URL */
76 int64_t bodySize; /**< Size of HTTP request body in bytes */
77 const uint8_t* body; /**< Buffer containg HTTP request body */
78 int64_t headersCount; /**< Number of HTTP request headers */
79 const mip_cc_http_header* headers; /**< Buffer containing HTTP request headers */
81
82/**
83 * @brief HTTP response
84 */
85typedef struct {
86 const char* id; /**< Unique request ID--correlated with the same property in mip_cc_http_request */
87 int32_t statusCode; /**< HTTP response status code */
88 int64_t bodySize; /**< Size of HTTP response body in bytes */
89 const uint8_t* body; /**< Buffer containg HTTP response body */
90 int64_t headersCount; /**< Number of HTTP response headers */
91 const mip_cc_http_header* headers; /**< Buffer containing HTTP response headers */
93
94/**
95 * @brief Callback function definition for issuing an HTTP request
96 *
97 * @param request The HTTP request to be performed by the application
98 * @param context The same opaque context passed to MIP API call that resulted in this HTTP request
99 */
100MIP_CC_CALLBACK(mip_cc_http_send_callback_fn /*typename*/,
101 void /*return*/,
102 const mip_cc_http_request* /*request*/,
103 const void* /*context*/);
104
105/**
106 * @brief Callback function definition for cancelling an HTTP request
107 *
108 * @param requestId The ID of the HTTP request to be cancelled
109 */
110MIP_CC_CALLBACK(mip_cc_http_cancel_callback_fn /*typename*/,
111 void /*return*/,
112 const char* /*requestId*/);
113
115
116/**
117 * @brief Creates an HTTP delegate which can be used to override MIP's default HTTP stack
118 *
119 * @param sendCallback Function pointer for issuing HTTP requests
120 * @param cancelCallback Function pointer for cancelling HTTP requests
121 * @param httpDelegate [Output] Handle to HTTP delegate object
122 * @param errorInfo [Output] (Optional) Failure info if operation result is error
123 *
124 * @return Result code indicating success or failure
125 */
126MIP_CC_API(mip_cc_result) MIP_CC_CreateHttpDelegate(
127 const mip_cc_http_send_callback_fn sendCallback,
128 const mip_cc_http_cancel_callback_fn cancelCallback,
131
132/**
133 * @brief Notifies an HTTP delegate that an HTTP response is ready
134 *
135 * @param httpDelegate Handle to HTTP delegate object
136 * @param requestId ID of HTTP request associated with this operation
137 * @param result Success/failure state of operation
138 * @param response The HTTP response if operation succeeded, else nullptr
139 *
140 * @note This function must be called by the application when an HTTP operation has completed. The ID of the HTTP
141 * response must match the ID of the HTTP request to allow MIP to correlate a response with its request
142 */
143MIP_CC_API(void) MIP_CC_NotifyHttpDelegateResponse(
145 const char* requestId,
148
149/**
150 * @brief Release resources associated with an HTTP delegate handle
151 *
152 * @param httpDelegate HTTP delegate to be released
153 */
154MIP_CC_API(void) MIP_CC_ReleaseHttpDelegate(mip_cc_http_delegate httpDelegate);
155
156#endif // API_MIP_HTTP_DELEGATE_CC_H_
A file Containing the common types used by the upe, file and protection modules.
Error definition and functions.
const char const mip_cc_http_result result
mip_cc_http_request_type
HTTP request type.
@ HTTP_REQUEST_TYPE_GET
HTTP GET.
@ HTTP_REQUEST_TYPE_POST
HTTP POST.
const mip_cc_http_cancel_callback_fn mip_cc_http_delegate mip_cc_error * errorInfo
mip_cc_handle * mip_cc_http_delegate
const char const mip_cc_http_result const mip_cc_http_response * response
const mip_cc_http_cancel_callback_fn mip_cc_http_delegate * httpDelegate
const char * requestId
const mip_cc_http_cancel_callback_fn cancelCallback
mip_cc_http_result
Success/failure state of the HTTP operation.
@ HTTP_RESULT_FAILURE
HTTP operation failed (e.g.
@ HTTP_RESULT_OK
HTTP operation was completed successfull.
MIP_CC_CALLBACK(mip_cc_http_send_callback_fn, void, const mip_cc_http_request *, const void *)
Callback function definition for issuing an HTTP request.
MIP_CC_API(void) MIP_CC_NotifyHttpDelegateResponse(const mip_cc_http_delegate httpDelegate
Notifies an HTTP delegate that an HTTP response is ready.
Export/import and other macros for C API.
Defines success/error result codes.
mip_cc_result
API success/failure result.
Definition result_cc.h:44
Error information.
Definition error_cc.h:79
Opaque handle to MIP object.
HTTP request/response header.
const char * name
Header name/key.
const char * value
Header value.
int64_t bodySize
Size of HTTP request body in bytes.
const char * url
HTTP request URL.
int64_t headersCount
Number of HTTP request headers.
const mip_cc_http_header * headers
Buffer containing HTTP request headers.
mip_cc_http_request_type type
HTTP request type (e.g.
const uint8_t * body
Buffer containg HTTP request body.
const char * id
Unique request ID–correlated with the same property in mip_cc_http_response.
const mip_cc_http_header * headers
Buffer containing HTTP response headers.
int64_t bodySize
Size of HTTP response body in bytes.
int32_t statusCode
HTTP response status code.
int64_t headersCount
Number of HTTP response headers.
const char * id
Unique request ID–correlated with the same property in mip_cc_http_request.
const uint8_t * body
Buffer containg HTTP response body.