1 | /* $Id: tstHttp.cpp 43645 2012-10-15 14:10:03Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * IPRT Testcase - Simple cURL testcase.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2012 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.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 | /*******************************************************************************
|
---|
28 | * Header Files *
|
---|
29 | *******************************************************************************/
|
---|
30 | #include <iprt/err.h>
|
---|
31 | #include <iprt/http.h>
|
---|
32 | #include <iprt/mem.h>
|
---|
33 | #include <iprt/stream.h>
|
---|
34 | #include <iprt/initterm.h>
|
---|
35 | #include <iprt/thread.h>
|
---|
36 |
|
---|
37 | int main()
|
---|
38 | {
|
---|
39 | unsigned cErrors = 0;
|
---|
40 |
|
---|
41 | RTR3InitExeNoArguments(RTR3INIT_FLAGS_SUPLIB);
|
---|
42 |
|
---|
43 | RTHTTP hHttp;
|
---|
44 | int rc = RTHttpCreate(&hHttp);
|
---|
45 | char *pszBuf = NULL;
|
---|
46 | if (RT_SUCCESS(rc))
|
---|
47 | rc = RTHttpGet(hHttp,
|
---|
48 | "https://update.virtualbox.org/query.php?platform=LINUX_32BITS_UBUNTU_12_04&version=4.1.18",
|
---|
49 | &pszBuf);
|
---|
50 | RTHttpDestroy(hHttp);
|
---|
51 |
|
---|
52 | RTPrintf("Error code: %Rrc\nGot: %s\n", rc, pszBuf);
|
---|
53 | RTMemFree(pszBuf);
|
---|
54 |
|
---|
55 | return !!cErrors;
|
---|
56 | }
|
---|