http.h revision 194b1350067bed46156efacc6a39044fc3fa64db
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/* $Id$ */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** @file
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * IPRT - Simple HTTP Communication API.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/*
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Copyright (C) 2012 Oracle Corporation
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * available from http://www.virtualbox.org. This file is free software;
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * you can redistribute it and/or modify it under the terms of the GNU
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * General Public License (GPL) as published by the Free Software
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * The contents of this file may alternatively be used under the terms
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * of the Common Development and Distribution License Version 1.0
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * VirtualBox OSE distribution, in which case the provisions of the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * CDDL are applicable instead of those of the GPL.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * You may elect to license modified versions of this file under the
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * terms and conditions of either the GPL or the CDDL or both.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#ifndef ___iprt_http_h
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#define ___iprt_http_h
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#include <iprt/types.h>
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncRT_C_DECLS_BEGIN
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** @defgroup grp_rt_http RTHttp - Simple HTTP API
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @ingroup grp_rt
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @{
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** @todo the following three definitions may move the iprt/types.h later. */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** RTHTTP interface handle. */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsynctypedef R3PTRTYPE(struct RTHTTPINTERNAL *) RTHTTP;
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** Pointer to a RTHTTP interface handle. */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsynctypedef RTHTTP *PRTHTTP;
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** Nil RTHTTP interface handle. */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#define NIL_RTHTTP ((RTHTTP)0)
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/**
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Creates a HTTP interface handle.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @returns iprt status code.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @param phHttp Where to store the HTTP handle.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncRTR3DECL(int) RTHttpCreate(PRTHTTP phHttp);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/**
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Destroys a HTTP interface handle.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @param hHttp Handle to the HTTP interface.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncRTR3DECL(void) RTHttpDestroy(RTHTTP hHttp);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/**
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * Perform a simple blocking HTTP request.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @returns iprt status code.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync *
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @param hHttp HTTP interface handle.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @param pcszUrl URL.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync * @param ppszResponse HTTP response.
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncRTR3DECL(int) RTHttpGet(RTHTTP hHttp, const char *pcszUrl, char **ppszResponse);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
caee579e589670f6a9444912e548b74ed0764439vboxsync/**
caee579e589670f6a9444912e548b74ed0764439vboxsync * Specify proxy settings.
caee579e589670f6a9444912e548b74ed0764439vboxsync *
caee579e589670f6a9444912e548b74ed0764439vboxsync * @returns iprt status code.
caee579e589670f6a9444912e548b74ed0764439vboxsync *
caee579e589670f6a9444912e548b74ed0764439vboxsync * @param hHttp HTTP interface handle.
caee579e589670f6a9444912e548b74ed0764439vboxsync * @param pcszProxy URL of the proxy
caee579e589670f6a9444912e548b74ed0764439vboxsync * @param uPort port number of the proxy, use 0 for not specifying a port.
caee579e589670f6a9444912e548b74ed0764439vboxsync * @param pcszUser username, pass NULL for no authentication
caee579e589670f6a9444912e548b74ed0764439vboxsync * @param pcszPwd password, pass NULL for no authentication
caee579e589670f6a9444912e548b74ed0764439vboxsync */
caee579e589670f6a9444912e548b74ed0764439vboxsyncRTR3DECL(int) RTHttpSetProxy(RTHTTP hHttp, const char *pcszProxyUrl, uint32_t uPort,
caee579e589670f6a9444912e548b74ed0764439vboxsync const char *pcszProxyUser, const char *pcszProxyPwd);
caee579e589670f6a9444912e548b74ed0764439vboxsync
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync/**
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync * Set custom headers.
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync *
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync * @returns iprt status code.
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync *
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync * @param hHttp HTTP interface handle.
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync * @param cHeaders number of custom headers.
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync * @param pcszHeaders array of headers in form "foo: bar".
194b1350067bed46156efacc6a39044fc3fa64dbvboxsync */
194b1350067bed46156efacc6a39044fc3fa64dbvboxsyncRTR3DECL(int) RTHttpSetHeaders(RTHTTP hHttp, uint32_t cHeaders, const char *pcszHeaders[]);
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync/** @} */
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsyncRT_C_DECLS_END
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync#endif
55870b5b46ea9754616dcc3663a110ce71927a0evboxsync