EvalEmitDVArray: varray
[hiphop-php.git] / hphp / runtime / base / url-file.h
blob310638d430327d3682ca991a4447001fde74c9f4
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_URL_FILE_H_
18 #define incl_HPHP_URL_FILE_H_
20 #include "hphp/runtime/base/http-client.h"
21 #include "hphp/runtime/base/mem-file.h"
22 #include "hphp/runtime/base/string-buffer.h"
24 namespace HPHP {
25 ///////////////////////////////////////////////////////////////////////////////
27 /**
28 * url based files.
30 struct UrlFile : MemFile {
31 DECLARE_RESOURCE_ALLOCATION(UrlFile);
33 explicit UrlFile(const char *method = "GET", const Array& headers = null_array,
34 const String& postData = null_string,
35 int maxRedirect = HttpClient::defaultMaxRedirect,
36 int timeout = -1, bool ignoreErrors = false);
38 // overriding ResourceData
39 const String& o_getClassNameHook() const override { return classnameof(); }
41 void setProxy(const String& proxy_host, int proxy_port,
42 const String& proxy_user, const String& proxy_pass);
43 bool open(const String& filename, const String& mode) override;
44 int64_t writeImpl(const char *buffer, int64_t length) override;
45 bool seekable() override { return false; }
46 bool flush() override;
47 Variant getWrapperMetaData() override { return Variant(m_responseHeaders); }
48 String getLastError();
50 private:
51 bool m_get;
52 bool m_ignoreErrors;
53 const char* m_method;
54 Array m_headers;
55 String m_postData;
56 int m_maxRedirect;
57 int m_timeout;
58 std::string m_error;
59 StringBuffer m_response;
60 Array m_responseHeaders;
62 std::string m_proxyHost;
63 int m_proxyPort;
64 std::string m_proxyUsername;
65 std::string m_proxyPassword;
68 ///////////////////////////////////////////////////////////////////////////////
71 #endif // incl_HPHP_URL_FILE_H_