VirtualBox

source: vbox/trunk/include/iprt/http.h@ 57577

最後變更 在這個檔案從57577是 57577,由 vboxsync 提交於 10 年 前

IPRT,QtGui: Redid the certificate download code in the GUI and reduced the number of unnecessary wrapper methods. Removed RTHttpCertDigest, adding RTHttpFreeResponse and RTHttpFreeResponseText. Also added RTCrPemParseContent.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 6.3 KB
 
1/* $Id: http.h 57577 2015-08-28 18:57:36Z vboxsync $ */
2/** @file
3 * IPRT - Simple HTTP Communication API.
4 */
5
6/*
7 * Copyright (C) 2012-2015 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___iprt_http_h
28#define ___iprt_http_h
29
30#include <iprt/types.h>
31
32RT_C_DECLS_BEGIN
33
34/** @defgroup grp_rt_http RTHttp - Simple HTTP API
35 * @ingroup grp_rt
36 * @{
37 */
38
39/** @todo the following three definitions may move the iprt/types.h later. */
40/** RTHTTP interface handle. */
41typedef R3PTRTYPE(struct RTHTTPINTERNAL *) RTHTTP;
42/** Pointer to a RTHTTP interface handle. */
43typedef RTHTTP *PRTHTTP;
44/** Nil RTHTTP interface handle. */
45#define NIL_RTHTTP ((RTHTTP)0)
46
47
48/**
49 * Creates a HTTP interface handle.
50 *
51 * @returns iprt status code.
52 *
53 * @param phHttp Where to store the HTTP handle.
54 */
55RTR3DECL(int) RTHttpCreate(PRTHTTP phHttp);
56
57/**
58 * Destroys a HTTP interface handle.
59 *
60 * @param hHttp Handle to the HTTP interface.
61 */
62RTR3DECL(void) RTHttpDestroy(RTHTTP hHttp);
63
64
65/**
66 * Retrieve the redir location for 301 responses.
67 *
68 * @param hHttp Handle to the HTTP interface.
69 * @param ppszRedirLocation Where to store the string. To be freed with
70 * RTStrFree().
71 */
72RTR3DECL(int) RTHttpGetRedirLocation(RTHTTP hHttp, char **ppszRedirLocation);
73
74/**
75 * Perform a simple blocking HTTP request.
76 *
77 * This is a just a convenient wrapper around RTHttpGetBinary that returns a
78 * different type and sheds a parameter.
79 *
80 * @returns iprt status code.
81 *
82 * @param hHttp HTTP interface handle.
83 * @param pcszUrl URL.
84 * @param ppszNotUtf8 Where to return the poitner to the HTTP response.
85 * The string is of course zero terminated. Use
86 * RTHttpFreeReponseText to free.
87 *
88 * @remarks BIG FAT WARNING!
89 *
90 * This function does not guarantee the that returned string is valid UTF-8 or
91 * any other kind of text encoding!
92 *
93 * The caller must determine and validate the string encoding _before_
94 * passing it along to functions that expect UTF-8!
95 *
96 * Also, this function does not guarantee that the returned string
97 * doesn't have embedded zeros and provides the caller no way of
98 * finding out! If you are worried about the response from the HTTPD
99 * containing embedded zero's, use RTHttpGetBinary instead.
100 */
101RTR3DECL(int) RTHttpGetText(RTHTTP hHttp, const char *pcszUrl, char **ppszNotUtf8);
102
103/**
104 * Frees memory returned by RTHttpGetText.
105 *
106 * @param pszNotUtf8 What RTHttpGetText returned.
107 */
108RTR3DECL(void) RTHttpFreeResponseText(char *pszNotUtf8);
109
110/**
111 * Perform a simple blocking HTTP request.
112 *
113 * @returns iprt status code.
114 *
115 * @param hHttp HTTP interface handle.
116 * @param pcszUrl The URL.
117 * @param ppvResponse Where to store the HTTP response data. Use
118 * RTHttpFreeResponse to free.
119 * @param pcb Size of the returned buffer.
120 */
121RTR3DECL(int) RTHttpGetBinary(RTHTTP hHttp, const char *pcszUrl, void **ppvResponse, size_t *pcb);
122
123/**
124 * Frees memory returned by RTHttpGetBinary.
125 *
126 * @param pvResponse What RTHttpGetBinary returned.
127 */
128RTR3DECL(void) RTHttpFreeResponse(void *pvResponse);
129
130/**
131 * Perform a simple blocking HTTP request, writing the output to a file.
132 *
133 * @returns iprt status code.
134 *
135 * @param hHttp HTTP interface handle.
136 * @param pszUrl The URL.
137 * @param pszDstFile The destination file name.
138 */
139RTR3DECL(int) RTHttpGetFile(RTHTTP hHttp, const char *pszUrl, const char *pszDstFile);
140
141/**
142 * Abort a pending HTTP request. A blocking RTHttpGet() call will return with
143 * VERR_HTTP_ABORTED. It may take some time (current cURL implementation needs
144 * up to 1 second) before the request is aborted.
145 *
146 * @returns iprt status code.
147 *
148 * @param hHttp HTTP interface handle.
149 */
150RTR3DECL(int) RTHttpAbort(RTHTTP hHttp);
151
152/**
153 * Tells the HTTP interface to use the system proxy configuration.
154 *
155 * @returns iprt status code.
156 * @param hHttp HTTP interface handle.
157 */
158RTR3DECL(int) RTHttpUseSystemProxySettings(RTHTTP hHttp);
159
160/**
161 * Specify proxy settings.
162 *
163 * @returns iprt status code.
164 *
165 * @param hHttp HTTP interface handle.
166 * @param pcszProxy URL of the proxy.
167 * @param uPort port number of the proxy, use 0 for not specifying a port.
168 * @param pcszUser Username, pass NULL for no authentication.
169 * @param pcszPwd Password, pass NULL for no authentication.
170 */
171RTR3DECL(int) RTHttpSetProxy(RTHTTP hHttp, const char *pcszProxyUrl, uint32_t uPort,
172 const char *pcszProxyUser, const char *pcszProxyPwd);
173
174/**
175 * Set custom headers.
176 *
177 * @returns iprt status code.
178 *
179 * @param hHttp HTTP interface handle.
180 * @param cHeaders Number of custom headers.
181 * @param pcszHeaders Array of headers in form "foo: bar".
182 */
183RTR3DECL(int) RTHttpSetHeaders(RTHTTP hHttp, size_t cHeaders, const char * const *papszHeaders);
184
185/**
186 * Set a custom certification authority file, containing root certificates.
187 *
188 * @returns iprt status code.
189 *
190 * @param hHttp HTTP interface handle.
191 * @param pcszCAFile File name containing root certificates.
192 */
193RTR3DECL(int) RTHttpSetCAFile(RTHTTP hHttp, const char *pcszCAFile);
194
195
196/** @} */
197
198RT_C_DECLS_END
199
200#endif
201
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette