cpl_http.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /******************************************************************************
  2. * $Id: cpl_http.h 27044 2014-03-16 23:41:27Z rouault $
  3. *
  4. * Project: Common Portability Library
  5. * Purpose: Function wrapper for libcurl HTTP access.
  6. * Author: Frank Warmerdam, warmerdam@pobox.com
  7. *
  8. ******************************************************************************
  9. * Copyright (c) 2006, Frank Warmerdam
  10. * Copyright (c) 2009, Even Rouault <even dot rouault at mines-paris dot org>
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a
  13. * copy of this software and associated documentation files (the "Software"),
  14. * to deal in the Software without restriction, including without limitation
  15. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  16. * and/or sell copies of the Software, and to permit persons to whom the
  17. * Software is furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included
  20. * in all copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  23. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  25. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  27. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  28. * DEALINGS IN THE SOFTWARE.
  29. ****************************************************************************/
  30. #ifndef CPL_HTTP_H_INCLUDED
  31. #define CPL_HTTP_H_INCLUDED
  32. #include "cpl_conv.h"
  33. #include "cpl_string.h"
  34. #include "cpl_vsi.h"
  35. /**
  36. * \file cpl_http.h
  37. *
  38. * Interface for downloading HTTP, FTP documents
  39. */
  40. CPL_C_START
  41. /*! Describe a part of a multipart message */
  42. typedef struct {
  43. /*! NULL terminated array of headers */ char **papszHeaders;
  44. /*! Buffer with data of the part */ GByte *pabyData;
  45. /*! Buffer length */ int nDataLen;
  46. } CPLMimePart;
  47. /*! Describe the result of a CPLHTTPFetch() call */
  48. typedef struct {
  49. /*! cURL error code : 0=success, non-zero if request failed */
  50. int nStatus;
  51. /*! Content-Type of the response */
  52. char *pszContentType;
  53. /*! Error message from curl, or NULL */
  54. char *pszErrBuf;
  55. /*! Length of the pabyData buffer */
  56. int nDataLen;
  57. int nDataAlloc;
  58. /*! Buffer with downloaded data */
  59. GByte *pabyData;
  60. /*! Headers returned */
  61. char **papszHeaders;
  62. /*! Number of parts in a multipart message */
  63. int nMimePartCount;
  64. /*! Array of parts (resolved by CPLHTTPParseMultipartMime()) */
  65. CPLMimePart *pasMimePart;
  66. } CPLHTTPResult;
  67. int CPL_DLL CPLHTTPEnabled( void );
  68. CPLHTTPResult CPL_DLL *CPLHTTPFetch( const char *pszURL, char **papszOptions);
  69. void CPL_DLL CPLHTTPCleanup( void );
  70. void CPL_DLL CPLHTTPDestroyResult( CPLHTTPResult *psResult );
  71. int CPL_DLL CPLHTTPParseMultipartMime( CPLHTTPResult *psResult );
  72. /* -------------------------------------------------------------------- */
  73. /* The following is related to OAuth2 authorization around */
  74. /* google services like fusion tables, and potentially others */
  75. /* in the future. Code in cpl_google_oauth2.cpp. */
  76. /* */
  77. /* These services are built on CPL HTTP services. */
  78. /* -------------------------------------------------------------------- */
  79. char CPL_DLL *GOA2GetAuthorizationURL( const char *pszScope );
  80. char CPL_DLL *GOA2GetRefreshToken( const char *pszAuthToken,
  81. const char *pszScope );
  82. char CPL_DLL *GOA2GetAccessToken( const char *pszRefreshToken,
  83. const char *pszScope );
  84. CPL_C_END
  85. #endif /* ndef CPL_HTTP_H_INCLUDED */