WebMutableURLRequest.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef WebMutableURLRequest_H
  26. #define WebMutableURLRequest_H
  27. #include "WebKit.h"
  28. #include <WebCore/ResourceRequest.h>
  29. namespace WebCore
  30. {
  31. class FormData;
  32. }
  33. inline WebCore::ResourceRequestCachePolicy core(WebURLRequestCachePolicy policy)
  34. {
  35. return static_cast<WebCore::ResourceRequestCachePolicy>(policy);
  36. }
  37. inline WebURLRequestCachePolicy kit(WebCore::ResourceRequestCachePolicy policy)
  38. {
  39. return static_cast<WebURLRequestCachePolicy>(policy);
  40. }
  41. class WebMutableURLRequest : public IWebMutableURLRequest, IWebMutableURLRequestPrivate
  42. {
  43. public:
  44. static WebMutableURLRequest* createInstance();
  45. static WebMutableURLRequest* createInstance(IWebMutableURLRequest* req);
  46. static WebMutableURLRequest* createInstance(const WebCore::ResourceRequest&);
  47. static WebMutableURLRequest* createImmutableInstance();
  48. static WebMutableURLRequest* createImmutableInstance(const WebCore::ResourceRequest&);
  49. protected:
  50. WebMutableURLRequest(bool isMutable);
  51. ~WebMutableURLRequest();
  52. public:
  53. // IUnknown
  54. virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
  55. virtual ULONG STDMETHODCALLTYPE AddRef(void);
  56. virtual ULONG STDMETHODCALLTYPE Release(void);
  57. // IWebURLRequest
  58. virtual HRESULT STDMETHODCALLTYPE requestWithURL(
  59. /* [in] */ BSTR theURL,
  60. /* [optional][in] */ WebURLRequestCachePolicy cachePolicy,
  61. /* [optional][in] */ double timeoutInterval);
  62. virtual HRESULT STDMETHODCALLTYPE allHTTPHeaderFields(
  63. /* [retval][out] */ IPropertyBag **result);
  64. virtual HRESULT STDMETHODCALLTYPE cachePolicy(
  65. /* [retval][out] */ WebURLRequestCachePolicy *result);
  66. virtual HRESULT STDMETHODCALLTYPE HTTPBody(
  67. /* [retval][out] */ IStream **result);
  68. virtual HRESULT STDMETHODCALLTYPE HTTPBodyStream(
  69. /* [retval][out] */ IStream **result);
  70. virtual HRESULT STDMETHODCALLTYPE HTTPMethod(
  71. /* [retval][out] */ BSTR *result);
  72. virtual HRESULT STDMETHODCALLTYPE HTTPShouldHandleCookies(
  73. /* [retval][out] */ BOOL *result);
  74. virtual HRESULT STDMETHODCALLTYPE initWithURL(
  75. /* [in] */ BSTR url,
  76. /* [optional][in] */ WebURLRequestCachePolicy cachePolicy,
  77. /* [optional][in] */ double timeoutInterval);
  78. virtual HRESULT STDMETHODCALLTYPE mainDocumentURL(
  79. /* [retval][out] */ BSTR *result);
  80. virtual HRESULT STDMETHODCALLTYPE timeoutInterval(
  81. /* [retval][out] */ double *result);
  82. virtual HRESULT STDMETHODCALLTYPE URL(
  83. /* [retval][out] */ BSTR *result);
  84. virtual HRESULT STDMETHODCALLTYPE valueForHTTPHeaderField(
  85. /* [in] */ BSTR field,
  86. /* [retval][out] */ BSTR *result);
  87. virtual HRESULT STDMETHODCALLTYPE isEmpty(
  88. /* [retval][out] */ BOOL* result);
  89. virtual HRESULT STDMETHODCALLTYPE mutableCopy(
  90. /* [out, retval] */ IWebMutableURLRequest** result);
  91. virtual HRESULT STDMETHODCALLTYPE isEqual(
  92. /* [in] */ IWebURLRequest* other,
  93. /* [out, retval] */ BOOL* result);
  94. // IWebMutableURLRequest
  95. virtual HRESULT STDMETHODCALLTYPE addValue(
  96. /* [in] */ BSTR value,
  97. /* [in] */ BSTR field);
  98. virtual HRESULT STDMETHODCALLTYPE setAllHTTPHeaderFields(
  99. /* [in] */ IPropertyBag *headerFields);
  100. virtual HRESULT STDMETHODCALLTYPE setCachePolicy(
  101. /* [in] */ WebURLRequestCachePolicy policy);
  102. virtual HRESULT STDMETHODCALLTYPE setHTTPBody(
  103. /* [in] */ IStream *data);
  104. virtual HRESULT STDMETHODCALLTYPE setHTTPBodyStream(
  105. /* [in] */ IStream *data);
  106. virtual HRESULT STDMETHODCALLTYPE setHTTPMethod(
  107. /* [in] */ BSTR method);
  108. virtual HRESULT STDMETHODCALLTYPE setHTTPShouldHandleCookies(
  109. /* [in] */ BOOL handleCookies);
  110. virtual HRESULT STDMETHODCALLTYPE setMainDocumentURL(
  111. /* [in] */ BSTR theURL);
  112. virtual HRESULT STDMETHODCALLTYPE setTimeoutInterval(
  113. /* [in] */ double timeoutInterval);
  114. virtual HRESULT STDMETHODCALLTYPE setURL(
  115. /* [in] */ BSTR theURL);
  116. virtual HRESULT STDMETHODCALLTYPE setValue(
  117. /* [in] */ BSTR value,
  118. /* [in] */ BSTR field);
  119. virtual HRESULT STDMETHODCALLTYPE setAllowsAnyHTTPSCertificate(void);
  120. // IWebMutableURLRequestPrivate
  121. virtual HRESULT STDMETHODCALLTYPE setClientCertificate(
  122. /* [in] */ OLE_HANDLE cert);
  123. virtual /* [local] */ CFURLRequestRef STDMETHODCALLTYPE cfRequest();
  124. // WebMutableURLRequest
  125. void setFormData(const PassRefPtr<WebCore::FormData> data);
  126. const PassRefPtr<WebCore::FormData> formData() const;
  127. void addHTTPHeaderFields(const WebCore::HTTPHeaderMap& headerFields);
  128. const WebCore::HTTPHeaderMap& httpHeaderFields() const;
  129. const WebCore::ResourceRequest& resourceRequest() const;
  130. protected:
  131. ULONG m_refCount;
  132. bool m_isMutable;
  133. WebCore::ResourceRequest m_request;
  134. };
  135. #endif