Azure SDK for Embedded C
az_http_transport.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // SPDX-License-Identifier: MIT
3 
15 #ifndef _az_HTTP_TRANSPORT_H
16 #define _az_HTTP_TRANSPORT_H
17 
18 #include <azure/core/az_http.h>
19 #include <azure/core/az_span.h>
20 
21 #include <azure/core/_az_cfg_prefix.h>
22 
27 
31 AZ_INLINE az_http_method az_http_method_get() { return AZ_SPAN_FROM_STR("GET"); }
32 
36 AZ_INLINE az_http_method az_http_method_head() { return AZ_SPAN_FROM_STR("HEAD"); }
37 
41 AZ_INLINE az_http_method az_http_method_post() { return AZ_SPAN_FROM_STR("POST"); }
42 
46 AZ_INLINE az_http_method az_http_method_put() { return AZ_SPAN_FROM_STR("PUT"); }
47 
51 AZ_INLINE az_http_method az_http_method_delete() { return AZ_SPAN_FROM_STR("DELETE"); }
52 
56 AZ_INLINE az_http_method az_http_method_patch() { return AZ_SPAN_FROM_STR("PATCH"); }
57 
61 typedef struct
62 {
63  az_span name;
64  az_span value;
65 } _az_http_request_header;
66 
72 
78 typedef struct
79 {
80  struct
81  {
82  az_context* context;
83  az_http_method method;
84  az_span url;
85  int32_t url_length;
86  int32_t query_start;
87  _az_http_request_headers headers; // Contains instances of _az_http_request_header
88  int32_t headers_length;
89  int32_t max_headers;
90  int32_t retry_headers_start_byte_offset;
91  az_span body;
92  } _internal;
94 
98 // Definition is below.
99 typedef struct _az_http_policy _az_http_policy;
100 
108 typedef AZ_NODISCARD az_result (*_az_http_policy_process_fn)(
109  _az_http_policy* ref_policies,
110  void* ref_options,
111  az_http_request* ref_request,
112  az_http_response* ref_response);
113 
118 struct _az_http_policy
119 {
120  struct
121  {
122  _az_http_policy_process_fn process;
123  void* options;
124  } _internal;
125 };
126 
140  az_http_request const* request,
141  int32_t index,
142  az_span* out_name,
143  az_span* out_value);
144 
157 AZ_NODISCARD az_result
159 
172 AZ_NODISCARD az_result az_http_request_get_url(az_http_request const* request, az_span* out_url);
173 
186 AZ_NODISCARD az_result az_http_request_get_body(az_http_request const* request, az_span* out_body);
187 
202 AZ_NODISCARD az_result az_http_response_append(az_http_response* ref_response, az_span source);
203 
211 AZ_NODISCARD int32_t az_http_request_headers_count(az_http_request const* request);
212 
230 AZ_NODISCARD az_result
232 
233 #include <azure/core/_az_cfg_suffix.h>
234 
235 #endif // _az_HTTP_TRANSPORT_H
az_http_method_get
AZ_INLINE az_http_method az_http_method_get()
HTTP GET method name.
Definition: az_http_transport.h:31
az_http_method_head
AZ_INLINE az_http_method az_http_method_head()
HTTP HEAD method name.
Definition: az_http_transport.h:36
az_http_client_send_request
AZ_NODISCARD az_result az_http_client_send_request(az_http_request const *request, az_http_response *ref_response)
Sends an HTTP request through the wire and write the response into ref_response.
az_http_method
az_span az_http_method
A type representing an HTTP method (POST, PUT, GET, DELETE, etc.).
Definition: az_http_transport.h:26
az_result
az_result
The type represents the various success and error conditions.
Definition: az_result.h:53
az_http_request_get_method
AZ_NODISCARD az_result az_http_request_get_method(az_http_request const *request, az_http_method *out_method)
Get method of an HTTP request.
az_http_request
Structure used to represent an HTTP request. It contains an HTTP method, URL, headers and body....
Definition: az_http_transport.h:79
az_http_method_delete
AZ_INLINE az_http_method az_http_method_delete()
HTTP DELETE method name.
Definition: az_http_transport.h:51
az_http_request_get_body
AZ_NODISCARD az_result az_http_request_get_body(az_http_request const *request, az_span *out_body)
Get body from an HTTP request.
az_http_response_append
AZ_NODISCARD az_result az_http_response_append(az_http_response *ref_response, az_span source)
This function is expected to be used by transport adapters like curl. Use it to write content from so...
az_http_method_post
AZ_INLINE az_http_method az_http_method_post()
HTTP POST method name.
Definition: az_http_transport.h:41
az_span.h
An az_span represents a contiguous byte buffer and is used for string manipulations,...
az_http_method_put
AZ_INLINE az_http_method az_http_method_put()
HTTP PUT method name.
Definition: az_http_transport.h:46
az_http.h
This header defines the types and functions your application uses to leverage HTTP request and respon...
AZ_SPAN_FROM_STR
#define AZ_SPAN_FROM_STR(STRING_LITERAL)
Returns an az_span expression over a literal string.
Definition: az_span.h:125
az_context
A context is a node within a tree that represents expiration times and key/value pairs.
Definition: az_context.h:37
az_http_request_get_header
AZ_NODISCARD az_result az_http_request_get_header(az_http_request const *request, int32_t index, az_span *out_name, az_span *out_value)
Gets the HTTP header by index.
az_http_request_headers_count
AZ_NODISCARD int32_t az_http_request_headers_count(az_http_request const *request)
Returns the number of headers within the request.
az_http_request_get_url
AZ_NODISCARD az_result az_http_request_get_url(az_http_request const *request, az_span *out_url)
Get the URL from an HTTP request.
az_http_method_patch
AZ_INLINE az_http_method az_http_method_patch()
HTTP PATCH method name.
Definition: az_http_transport.h:56
az_http_response
Allows you to parse an HTTP response's status line, headers, and body.
Definition: az_http.h:157
az_span
Represents a "view" over a byte buffer that represents a contiguous region of memory....
Definition: az_span.h:33