1 /* GStreamer 2 * Copyright (C) 2021 Igalia S.L. 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Library General Public 6 * License as published by the Free Software Foundation; either 7 * version 2 of the License, or (at your option) any later version. 8 * 9 * This library is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * Library General Public License for more 13 */ 14 15 #ifndef __GST_SOUP_STUB_H__ 16 #define __GST_SOUP_STUB_H__ 17 18 #include <glib.h> 19 #include <glib-object.h> 20 21 G_BEGIN_DECLS 22 23 typedef enum { 24 SOUP_LOGGER_LOG_NONE, 25 SOUP_LOGGER_LOG_MINIMAL, 26 SOUP_LOGGER_LOG_HEADERS, 27 SOUP_LOGGER_LOG_BODY 28 } SoupLoggerLogLevel; 29 30 typedef enum { 31 SOUP_MEMORY_STATIC, 32 SOUP_MEMORY_TAKE, 33 SOUP_MEMORY_COPY, 34 SOUP_MEMORY_TEMPORARY 35 } SoupMemoryUse; 36 37 typedef enum { 38 SOUP_MESSAGE_NO_REDIRECT = (1 << 1), 39 /* Removed from libsoup2. In libsoup3 this enum value is allocated to 40 SOUP_MESSAGE_IDEMPOTENT which we don't use in GStreamer. */ 41 SOUP_MESSAGE_OVERWRITE_CHUNKS = (1 << 3), 42 } SoupMessageFlags; 43 44 typedef enum { 45 SOUP_ENCODING_UNRECOGNIZED, 46 SOUP_ENCODING_NONE, 47 SOUP_ENCODING_CONTENT_LENGTH, 48 SOUP_ENCODING_EOF, 49 SOUP_ENCODING_CHUNKED, 50 SOUP_ENCODING_BYTERANGES 51 } SoupEncoding; 52 53 typedef enum { 54 SOUP_STATUS_NONE, 55 56 /* Transport Errors */ 57 SOUP_STATUS_CANCELLED = 1, 58 SOUP_STATUS_CANT_RESOLVE, 59 SOUP_STATUS_CANT_RESOLVE_PROXY, 60 SOUP_STATUS_CANT_CONNECT, 61 SOUP_STATUS_CANT_CONNECT_PROXY, 62 SOUP_STATUS_SSL_FAILED, 63 SOUP_STATUS_IO_ERROR, 64 SOUP_STATUS_MALFORMED, 65 SOUP_STATUS_TRY_AGAIN, 66 SOUP_STATUS_TOO_MANY_REDIRECTS, 67 SOUP_STATUS_TLS_FAILED, 68 69 SOUP_STATUS_CONTINUE = 100, 70 SOUP_STATUS_SWITCHING_PROTOCOLS = 101, 71 SOUP_STATUS_PROCESSING = 102, /* WebDAV */ 72 73 SOUP_STATUS_OK = 200, 74 SOUP_STATUS_CREATED = 201, 75 SOUP_STATUS_ACCEPTED = 202, 76 SOUP_STATUS_NON_AUTHORITATIVE = 203, 77 SOUP_STATUS_NO_CONTENT = 204, 78 SOUP_STATUS_RESET_CONTENT = 205, 79 SOUP_STATUS_PARTIAL_CONTENT = 206, 80 SOUP_STATUS_MULTI_STATUS = 207, /* WebDAV */ 81 82 SOUP_STATUS_MULTIPLE_CHOICES = 300, 83 SOUP_STATUS_MOVED_PERMANENTLY = 301, 84 SOUP_STATUS_FOUND = 302, 85 SOUP_STATUS_MOVED_TEMPORARILY = 302, /* RFC 2068 */ 86 SOUP_STATUS_SEE_OTHER = 303, 87 SOUP_STATUS_NOT_MODIFIED = 304, 88 SOUP_STATUS_USE_PROXY = 305, 89 SOUP_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL = 306, /* (reserved) */ 90 SOUP_STATUS_TEMPORARY_REDIRECT = 307, 91 SOUP_STATUS_PERMANENT_REDIRECT = 308, 92 93 SOUP_STATUS_BAD_REQUEST = 400, 94 SOUP_STATUS_UNAUTHORIZED = 401, 95 SOUP_STATUS_PAYMENT_REQUIRED = 402, /* (reserved) */ 96 SOUP_STATUS_FORBIDDEN = 403, 97 SOUP_STATUS_NOT_FOUND = 404, 98 SOUP_STATUS_METHOD_NOT_ALLOWED = 405, 99 SOUP_STATUS_NOT_ACCEPTABLE = 406, 100 SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED = 407, 101 SOUP_STATUS_PROXY_UNAUTHORIZED = SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED, 102 SOUP_STATUS_REQUEST_TIMEOUT = 408, 103 SOUP_STATUS_CONFLICT = 409, 104 SOUP_STATUS_GONE = 410, 105 SOUP_STATUS_LENGTH_REQUIRED = 411, 106 SOUP_STATUS_PRECONDITION_FAILED = 412, 107 SOUP_STATUS_REQUEST_ENTITY_TOO_LARGE = 413, 108 SOUP_STATUS_REQUEST_URI_TOO_LONG = 414, 109 SOUP_STATUS_UNSUPPORTED_MEDIA_TYPE = 415, 110 SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416, 111 SOUP_STATUS_INVALID_RANGE = SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE, 112 SOUP_STATUS_EXPECTATION_FAILED = 417, 113 SOUP_STATUS_MISDIRECTED_REQUEST = 421, /* HTTP/2 */ 114 SOUP_STATUS_UNPROCESSABLE_ENTITY = 422, /* WebDAV */ 115 SOUP_STATUS_LOCKED = 423, /* WebDAV */ 116 SOUP_STATUS_FAILED_DEPENDENCY = 424, /* WebDAV */ 117 118 SOUP_STATUS_INTERNAL_SERVER_ERROR = 500, 119 SOUP_STATUS_NOT_IMPLEMENTED = 501, 120 SOUP_STATUS_BAD_GATEWAY = 502, 121 SOUP_STATUS_SERVICE_UNAVAILABLE = 503, 122 SOUP_STATUS_GATEWAY_TIMEOUT = 504, 123 SOUP_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505, 124 SOUP_STATUS_INSUFFICIENT_STORAGE = 507, /* WebDAV search */ 125 SOUP_STATUS_NOT_EXTENDED = 510 /* RFC 2774 */ 126 } SoupStatus; 127 128 #define SOUP_STATUS_IS_SUCCESSFUL(status) ((status) >= 200 && (status) < 300) 129 #define SOUP_STATUS_IS_REDIRECTION(status) ((status) >= 300 && (status) < 400) 130 #define SOUP_STATUS_IS_CLIENT_ERROR(status) ((status) >= 400 && (status) < 500) 131 #define SOUP_STATUS_IS_SERVER_ERROR(status) ((status) >= 500 && (status) < 600) 132 #define SOUP_STATUS_IS_TRANSPORT_ERROR(status) ((status) > 0 && (status) < 100) 133 134 typedef gpointer SoupSession; 135 typedef gpointer SoupMessage; 136 typedef gpointer SoupLogger; 137 typedef gpointer SoupSessionFeature; 138 typedef gpointer SoupURI; 139 typedef gpointer SoupMessageBody; 140 typedef gpointer SoupMessageHeaders; 141 typedef gpointer SoupAuth; 142 143 typedef struct _SoupMessage2 { 144 GObject parent; 145 146 /*< public >*/ 147 const char *method; 148 149 guint status_code; 150 char *reason_phrase; 151 152 SoupMessageBody *request_body; 153 SoupMessageHeaders *request_headers; 154 155 SoupMessageBody *response_body; 156 SoupMessageHeaders *response_headers; 157 } SoupMessage2; 158 159 typedef void (*SoupLoggerPrinter)(SoupLogger *logger, 160 SoupLoggerLogLevel level, 161 char direction, 162 const char *data, 163 gpointer user_data); 164 165 #if GLIB_CHECK_VERSION(2, 68, 0) 166 #define SOUP_HTTP_URI_FLAGS \ 167 (G_URI_FLAGS_HAS_PASSWORD | G_URI_FLAGS_ENCODED_PATH | \ 168 G_URI_FLAGS_ENCODED_QUERY | G_URI_FLAGS_ENCODED_FRAGMENT | \ 169 G_URI_FLAGS_SCHEME_NORMALIZE) 170 #else 171 #define SOUP_HTTP_URI_FLAGS \ 172 (G_URI_FLAGS_HAS_PASSWORD | G_URI_FLAGS_ENCODED_PATH | \ 173 G_URI_FLAGS_ENCODED_QUERY | G_URI_FLAGS_ENCODED_FRAGMENT) 174 #endif 175 176 typedef void (*SoupMessageHeadersForeachFunc)(const char *name, 177 const char *value, 178 gpointer user_data); 179 180 /* Do not use these variables directly; use the macros above, which 181 * ensure that they get initialized properly. 182 */ 183 184 #if defined(__GNUC__) 185 #pragma GCC diagnostic push 186 #pragma GCC diagnostic ignored "-Wunused-variable" 187 #endif 188 static gpointer _SOUP_METHOD_OPTIONS; 189 static gpointer _SOUP_METHOD_GET; 190 static gpointer _SOUP_METHOD_HEAD; 191 static gpointer _SOUP_METHOD_POST; 192 #if defined(__GNUC__) 193 #pragma GCC diagnostic pop 194 #endif 195 196 #define _SOUP_ATOMIC_INTERN_STRING(variable, value) \ 197 ((const char *)(g_atomic_pointer_get(&(variable)) \ 198 ? (variable) \ 199 : (g_atomic_pointer_set( \ 200 &(variable), \ 201 (gpointer)g_intern_static_string(value)), \ 202 (variable)))) 203 204 #define _SOUP_INTERN_METHOD(method) \ 205 (_SOUP_ATOMIC_INTERN_STRING(_SOUP_METHOD_##method, #method)) 206 207 #define SOUP_METHOD_OPTIONS _SOUP_INTERN_METHOD(OPTIONS) 208 #define SOUP_METHOD_GET _SOUP_INTERN_METHOD(GET) 209 #define SOUP_METHOD_HEAD _SOUP_INTERN_METHOD(HEAD) 210 #define SOUP_METHOD_POST _SOUP_INTERN_METHOD(POST) 211 212 G_END_DECLS 213 214 #endif /* __GST_SOUP_STUB_H__ */ 215