InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IDHTTPRequest.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Mainak Biswas
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // ADOBE CONFIDENTIAL
16 //
17 // Copyright 2015 Adobe Systems Incorporated. All Rights Reserved.
18 //
19 // NOTICE: All information contained herein is, and remains
20 // the property of Adobe Systems Incorporated and its suppliers,
21 // if any. The intellectual and technical concepts contained
22 // herein are proprietary to Adobe Systems Incorporated and its
23 // suppliers and are protected by all applicable intellectual property
24 // laws, including trade secret and copyright laws.
25 // Dissemination of this information or reproduction of this material
26 // is strictly forbidden unless prior written permission is obtained
27 // from Adobe Systems Incorporated.
28 //
29 //
30 // Description:
31 // This class provides a wrapper over traditional uxtech::network:HTTPRequest implementation. The benefit of using this class is that any additional setup, like setting up
32 // request to communicate over authenticated proxy is automatically taken care of.
33 
34 // Currently This class only takes care of proxy related setup. Internally proxy credentials are shared between Adobe applications and this class uses the same internal
35 // mechanism to setup proxy credentials without exposing the credentials to users of this implementation.
36 //
37 // Currently this class provides very limited functionality. All network related API (like setting headers, reading response received etc) will be incrementally exposed via this
38 // implementation.
39 //
40 // TODO: Expose more networking API from this class to make it more usable.
41 //
42 //========================================================================================
43 
44 #ifndef __IDHTTPREQUEST_H__
45 #define __IDHTTPREQUEST_H__
46 
47 #include <uxtech/common/functional.hpp>
48 #include <uxtech/network/async_http.hpp>
49 #include <uxtech/thread/queue.hpp>
50 
52 {
53 public:
54  typedef std::function<void(IDHTTPRequest& request, uxtech::network::HttpResult result)> AsyncIDHttpRequestNotifier;
55 
56  IDHTTPRequest();
57  virtual ~IDHTTPRequest();
58 
63  virtual void SetUrl(const std::string url) { mUrl = url; }
64 
69  virtual void SetMethod(const std::string method) { mMethod = method; }
70 
75  virtual std::string GetUrl() { return mUrl; };
76 
81  virtual std::string GetMethod() { return mMethod; };
82 
89  virtual void ExecuteAsync(const AsyncIDHttpRequestNotifier& notifier, const uxtech::thread::QueuePtr& threadqueue);
90 
95  virtual uxtech::network::HttpResult ExecuteSync();
96 
97  // Private use - called during application shutdown explicitly to clean up any statically allocated IMSConnectionManager object references.
98  static void CleanupOnShutdown();
99 
100 private:
101  std::string mUrl;
102  std::string mMethod;
103  uxtech::network::HttpRequestPtr mRequest;
104  AsyncIDHttpRequestNotifier mNotifier;
105 
106  void AsyncUxtechHTTPResponseHandler(const uxtech::network::AsyncHttpRequestPtr& task, uxtech::network::HttpResult httpResult, const uxtech::network::HttpRequestPtr& request);
107 };
108 
109 #endif