quickfix_ruby_ud 2.0.7-aarch64-linux

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. checksums.yaml +7 -0
  2. data/ext/quickfix/Acceptor.cpp +257 -0
  3. data/ext/quickfix/Acceptor.h +127 -0
  4. data/ext/quickfix/Allocator.h +9 -0
  5. data/ext/quickfix/Application.h +137 -0
  6. data/ext/quickfix/DOMDocument.h +70 -0
  7. data/ext/quickfix/DataDictionary.cpp +679 -0
  8. data/ext/quickfix/DataDictionary.h +607 -0
  9. data/ext/quickfix/DataDictionaryProvider.cpp +66 -0
  10. data/ext/quickfix/DataDictionaryProvider.h +67 -0
  11. data/ext/quickfix/DatabaseConnectionID.h +98 -0
  12. data/ext/quickfix/DatabaseConnectionPool.h +84 -0
  13. data/ext/quickfix/Dictionary.cpp +157 -0
  14. data/ext/quickfix/Dictionary.h +89 -0
  15. data/ext/quickfix/Event.h +89 -0
  16. data/ext/quickfix/Except.h +39 -0
  17. data/ext/quickfix/Exceptions.h +257 -0
  18. data/ext/quickfix/Field.h +654 -0
  19. data/ext/quickfix/FieldConvertors.cpp +86 -0
  20. data/ext/quickfix/FieldConvertors.h +800 -0
  21. data/ext/quickfix/FieldMap.cpp +254 -0
  22. data/ext/quickfix/FieldMap.h +327 -0
  23. data/ext/quickfix/FieldNumbers.h +44 -0
  24. data/ext/quickfix/FieldTypes.cpp +62 -0
  25. data/ext/quickfix/FieldTypes.h +817 -0
  26. data/ext/quickfix/Fields.h +30 -0
  27. data/ext/quickfix/FileLog.cpp +176 -0
  28. data/ext/quickfix/FileLog.h +110 -0
  29. data/ext/quickfix/FileStore.cpp +369 -0
  30. data/ext/quickfix/FileStore.h +131 -0
  31. data/ext/quickfix/FixCommonFields.h +13 -0
  32. data/ext/quickfix/FixFieldNumbers.h +6132 -0
  33. data/ext/quickfix/FixFields.h +6133 -0
  34. data/ext/quickfix/FixValues.h +5790 -0
  35. data/ext/quickfix/Group.cpp +44 -0
  36. data/ext/quickfix/Group.h +78 -0
  37. data/ext/quickfix/HostDetailsProvider.cpp +79 -0
  38. data/ext/quickfix/HostDetailsProvider.h +44 -0
  39. data/ext/quickfix/HtmlBuilder.h +178 -0
  40. data/ext/quickfix/HttpConnection.cpp +914 -0
  41. data/ext/quickfix/HttpConnection.h +74 -0
  42. data/ext/quickfix/HttpMessage.cpp +229 -0
  43. data/ext/quickfix/HttpMessage.h +112 -0
  44. data/ext/quickfix/HttpParser.cpp +49 -0
  45. data/ext/quickfix/HttpParser.h +49 -0
  46. data/ext/quickfix/HttpServer.cpp +152 -0
  47. data/ext/quickfix/HttpServer.h +76 -0
  48. data/ext/quickfix/Initiator.cpp +310 -0
  49. data/ext/quickfix/Initiator.h +151 -0
  50. data/ext/quickfix/Log.cpp +71 -0
  51. data/ext/quickfix/Log.h +254 -0
  52. data/ext/quickfix/Message.cpp +617 -0
  53. data/ext/quickfix/Message.h +419 -0
  54. data/ext/quickfix/MessageCracker.h +171 -0
  55. data/ext/quickfix/MessageSorters.cpp +101 -0
  56. data/ext/quickfix/MessageSorters.h +185 -0
  57. data/ext/quickfix/MessageStore.cpp +182 -0
  58. data/ext/quickfix/MessageStore.h +164 -0
  59. data/ext/quickfix/Mutex.h +120 -0
  60. data/ext/quickfix/MySQLConnection.h +187 -0
  61. data/ext/quickfix/MySQLLog.cpp +262 -0
  62. data/ext/quickfix/MySQLLog.h +158 -0
  63. data/ext/quickfix/MySQLStore.cpp +323 -0
  64. data/ext/quickfix/MySQLStore.h +161 -0
  65. data/ext/quickfix/MySQLStubs.h +203 -0
  66. data/ext/quickfix/NullStore.cpp +40 -0
  67. data/ext/quickfix/NullStore.h +89 -0
  68. data/ext/quickfix/OdbcConnection.h +241 -0
  69. data/ext/quickfix/OdbcLog.cpp +230 -0
  70. data/ext/quickfix/OdbcLog.h +109 -0
  71. data/ext/quickfix/OdbcStore.cpp +313 -0
  72. data/ext/quickfix/OdbcStore.h +124 -0
  73. data/ext/quickfix/PUGIXML_DOMDocument.cpp +112 -0
  74. data/ext/quickfix/PUGIXML_DOMDocument.h +81 -0
  75. data/ext/quickfix/Parser.cpp +111 -0
  76. data/ext/quickfix/Parser.h +50 -0
  77. data/ext/quickfix/PostgreSQLConnection.h +163 -0
  78. data/ext/quickfix/PostgreSQLLog.cpp +263 -0
  79. data/ext/quickfix/PostgreSQLLog.h +157 -0
  80. data/ext/quickfix/PostgreSQLStore.cpp +327 -0
  81. data/ext/quickfix/PostgreSQLStore.h +160 -0
  82. data/ext/quickfix/PostgreSQLStubs.h +203 -0
  83. data/ext/quickfix/Queue.h +66 -0
  84. data/ext/quickfix/QuickfixRuby.cpp +131900 -0
  85. data/ext/quickfix/QuickfixRuby.h +56 -0
  86. data/ext/quickfix/Responder.h +41 -0
  87. data/ext/quickfix/SSLSocketAcceptor.cpp +409 -0
  88. data/ext/quickfix/SSLSocketAcceptor.h +186 -0
  89. data/ext/quickfix/SSLSocketConnection.cpp +434 -0
  90. data/ext/quickfix/SSLSocketConnection.h +221 -0
  91. data/ext/quickfix/SSLSocketInitiator.cpp +558 -0
  92. data/ext/quickfix/SSLSocketInitiator.h +203 -0
  93. data/ext/quickfix/SSLStubs.h +129 -0
  94. data/ext/quickfix/Session.cpp +1437 -0
  95. data/ext/quickfix/Session.h +343 -0
  96. data/ext/quickfix/SessionFactory.cpp +314 -0
  97. data/ext/quickfix/SessionFactory.h +84 -0
  98. data/ext/quickfix/SessionID.h +136 -0
  99. data/ext/quickfix/SessionSettings.cpp +165 -0
  100. data/ext/quickfix/SessionSettings.h +283 -0
  101. data/ext/quickfix/SessionState.h +260 -0
  102. data/ext/quickfix/Settings.cpp +160 -0
  103. data/ext/quickfix/Settings.h +56 -0
  104. data/ext/quickfix/SharedArray.h +274 -0
  105. data/ext/quickfix/SocketAcceptor.cpp +216 -0
  106. data/ext/quickfix/SocketAcceptor.h +77 -0
  107. data/ext/quickfix/SocketConnection.cpp +256 -0
  108. data/ext/quickfix/SocketConnection.h +102 -0
  109. data/ext/quickfix/SocketConnector.cpp +112 -0
  110. data/ext/quickfix/SocketConnector.h +76 -0
  111. data/ext/quickfix/SocketInitiator.cpp +241 -0
  112. data/ext/quickfix/SocketInitiator.h +76 -0
  113. data/ext/quickfix/SocketMonitor.h +26 -0
  114. data/ext/quickfix/SocketMonitor_UNIX.cpp +238 -0
  115. data/ext/quickfix/SocketMonitor_UNIX.h +101 -0
  116. data/ext/quickfix/SocketMonitor_WIN32.cpp +248 -0
  117. data/ext/quickfix/SocketMonitor_WIN32.h +99 -0
  118. data/ext/quickfix/SocketServer.cpp +163 -0
  119. data/ext/quickfix/SocketServer.h +100 -0
  120. data/ext/quickfix/ThreadedSSLSocketAcceptor.cpp +436 -0
  121. data/ext/quickfix/ThreadedSSLSocketAcceptor.h +209 -0
  122. data/ext/quickfix/ThreadedSSLSocketConnection.cpp +364 -0
  123. data/ext/quickfix/ThreadedSSLSocketConnection.h +191 -0
  124. data/ext/quickfix/ThreadedSSLSocketInitiator.cpp +434 -0
  125. data/ext/quickfix/ThreadedSSLSocketInitiator.h +193 -0
  126. data/ext/quickfix/ThreadedSocketAcceptor.cpp +242 -0
  127. data/ext/quickfix/ThreadedSocketAcceptor.h +95 -0
  128. data/ext/quickfix/ThreadedSocketConnection.cpp +227 -0
  129. data/ext/quickfix/ThreadedSocketConnection.h +89 -0
  130. data/ext/quickfix/ThreadedSocketInitiator.cpp +238 -0
  131. data/ext/quickfix/ThreadedSocketInitiator.h +78 -0
  132. data/ext/quickfix/TimeRange.cpp +227 -0
  133. data/ext/quickfix/TimeRange.h +215 -0
  134. data/ext/quickfix/Utility.cpp +639 -0
  135. data/ext/quickfix/Utility.h +255 -0
  136. data/ext/quickfix/UtilitySSL.cpp +1612 -0
  137. data/ext/quickfix/UtilitySSL.h +274 -0
  138. data/ext/quickfix/Values.h +63 -0
  139. data/ext/quickfix/config-all.h +10 -0
  140. data/ext/quickfix/config.h +10 -0
  141. data/ext/quickfix/config_unix.h +178 -0
  142. data/ext/quickfix/config_windows.h +0 -0
  143. data/ext/quickfix/dirent_windows.h +838 -0
  144. data/ext/quickfix/double-conversion/bignum-dtoa.cc +641 -0
  145. data/ext/quickfix/double-conversion/bignum-dtoa.h +84 -0
  146. data/ext/quickfix/double-conversion/bignum.cc +766 -0
  147. data/ext/quickfix/double-conversion/bignum.h +144 -0
  148. data/ext/quickfix/double-conversion/cached-powers.cc +176 -0
  149. data/ext/quickfix/double-conversion/cached-powers.h +64 -0
  150. data/ext/quickfix/double-conversion/diy-fp.cc +57 -0
  151. data/ext/quickfix/double-conversion/diy-fp.h +118 -0
  152. data/ext/quickfix/double-conversion/double-conversion.cc +994 -0
  153. data/ext/quickfix/double-conversion/double-conversion.h +543 -0
  154. data/ext/quickfix/double-conversion/fast-dtoa.cc +665 -0
  155. data/ext/quickfix/double-conversion/fast-dtoa.h +88 -0
  156. data/ext/quickfix/double-conversion/fixed-dtoa.cc +404 -0
  157. data/ext/quickfix/double-conversion/fixed-dtoa.h +56 -0
  158. data/ext/quickfix/double-conversion/ieee.h +402 -0
  159. data/ext/quickfix/double-conversion/strtod.cc +557 -0
  160. data/ext/quickfix/double-conversion/strtod.h +45 -0
  161. data/ext/quickfix/double-conversion/utils.h +374 -0
  162. data/ext/quickfix/extconf.rb +76 -0
  163. data/ext/quickfix/index.h +37 -0
  164. data/ext/quickfix/pugiconfig.hpp +77 -0
  165. data/ext/quickfix/pugixml.cpp +13237 -0
  166. data/ext/quickfix/pugixml.hpp +1516 -0
  167. data/ext/quickfix/scope_guard.hpp +215 -0
  168. data/ext/quickfix/stdint_msvc.h +254 -0
  169. data/ext/quickfix/strptime.h +7 -0
  170. data/lib/2.4/quickfix.so +0 -0
  171. data/lib/2.5/quickfix.so +0 -0
  172. data/lib/2.6/quickfix.so +0 -0
  173. data/lib/2.7/quickfix.so +0 -0
  174. data/lib/3.0/quickfix.so +0 -0
  175. data/lib/3.1/quickfix.so +0 -0
  176. data/lib/3.2/quickfix.so +0 -0
  177. data/lib/3.3/quickfix.so +0 -0
  178. data/lib/3.4/quickfix.so +0 -0
  179. data/lib/quickfix40.rb +274 -0
  180. data/lib/quickfix41.rb +351 -0
  181. data/lib/quickfix42.rb +1184 -0
  182. data/lib/quickfix43.rb +3504 -0
  183. data/lib/quickfix44.rb +14040 -0
  184. data/lib/quickfix50.rb +20051 -0
  185. data/lib/quickfix50sp1.rb +23596 -0
  186. data/lib/quickfix50sp2.rb +412444 -0
  187. data/lib/quickfix_fields.rb +79393 -0
  188. data/lib/quickfix_ruby.rb +82 -0
  189. data/lib/quickfixt11.rb +65 -0
  190. data/spec/FIX40.xml +862 -0
  191. data/spec/FIX41.xml +1282 -0
  192. data/spec/FIX42.xml +2743 -0
  193. data/spec/FIX43.xml +4230 -0
  194. data/spec/FIX44.xml +6600 -0
  195. data/spec/FIX50.xml +8142 -0
  196. data/spec/FIX50SP1.xml +9506 -0
  197. data/spec/FIX50SP2.xml +26069 -0
  198. data/spec/FIXT11.xml +252 -0
  199. data/test/DataDictionaryTestCase.rb +268 -0
  200. data/test/DictionaryTestCase.rb +112 -0
  201. data/test/FieldBaseTestCase.rb +24 -0
  202. data/test/MessageStoreTestCase.rb +19 -0
  203. data/test/MessageTestCase.rb +368 -0
  204. data/test/SessionSettingsTestCase.rb +41 -0
  205. metadata +247 -0
@@ -0,0 +1,74 @@
1
+ /* -*- C++ -*- */
2
+
3
+ /****************************************************************************
4
+ ** Copyright (c) 2001-2014
5
+ **
6
+ ** This file is part of the QuickFIX FIX Engine
7
+ **
8
+ ** This file may be distributed under the terms of the quickfixengine.org
9
+ ** license as defined by quickfixengine.org and appearing in the file
10
+ ** LICENSE included in the packaging of this file.
11
+ **
12
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
+ **
15
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
16
+ **
17
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
18
+ ** not clear to you.
19
+ **
20
+ ****************************************************************************/
21
+
22
+ #ifndef FIX_HTTPCONNECTION_H
23
+ #define FIX_HTTPCONNECTION_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "HttpParser.h"
30
+ #include <stdio.h>
31
+
32
+ namespace FIX {
33
+ class HttpMessage;
34
+
35
+ /// Encapsulates a HTTP socket file descriptor
36
+ class HttpConnection {
37
+ public:
38
+ HttpConnection(socket_handle s);
39
+
40
+ socket_handle getSocket() const { return m_socket; }
41
+ bool read();
42
+
43
+ private:
44
+ bool readMessage(std::string &msg) EXCEPT(SocketRecvFailed);
45
+ void processStream();
46
+ void processRequest(const HttpMessage &);
47
+ void processRoot(const HttpMessage &, std::stringstream &h, std::stringstream &b);
48
+ void processResetSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b);
49
+ void processRefreshSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b);
50
+ void processEnableSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b);
51
+ void processDisableSessions(const HttpMessage &, std::stringstream &h, std::stringstream &b);
52
+ void processSession(const HttpMessage &, std::stringstream &h, std::stringstream &b);
53
+ void processResetSession(const HttpMessage &, std::stringstream &h, std::stringstream &b);
54
+ void processRefreshSession(const HttpMessage &, std::stringstream &h, std::stringstream &b);
55
+
56
+ void showToggle(std::stringstream &s, const std::string &name, bool value, const std::string &url);
57
+ void showRow(std::stringstream &s, const std::string &name, bool value, const std::string &url = "");
58
+ void showRow(std::stringstream &s, const std::string &name, const std::string &value, const std::string &url = "");
59
+ void showRow(std::stringstream &s, const std::string &name, int value, const std::string &url = "");
60
+
61
+ bool send(const std::string &);
62
+ void disconnect(int error = 0);
63
+
64
+ socket_handle m_socket;
65
+ char m_buffer[BUFSIZ];
66
+
67
+ HttpParser m_parser;
68
+ #if _MSC_VER
69
+ fd_set m_fds;
70
+ #endif
71
+ };
72
+ } // namespace FIX
73
+
74
+ #endif
@@ -0,0 +1,229 @@
1
+ /****************************************************************************
2
+ ** Copyright (c) 2001-2014
3
+ **
4
+ ** This file is part of the QuickFIX FIX Engine
5
+ **
6
+ ** This file may be distributed under the terms of the quickfixengine.org
7
+ ** license as defined by quickfixengine.org and appearing in the file
8
+ ** LICENSE included in the packaging of this file.
9
+ **
10
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12
+ **
13
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
14
+ **
15
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
16
+ ** not clear to you.
17
+ **
18
+ ****************************************************************************/
19
+
20
+ #ifdef _MSC_VER
21
+ #include "stdafx.h"
22
+ #else
23
+ #include "config.h"
24
+ #endif
25
+
26
+ #include "HttpMessage.h"
27
+ #include "Utility.h"
28
+ #include <iomanip>
29
+ #include <sstream>
30
+
31
+ namespace FIX {
32
+
33
+ HttpMessage::HttpMessage() {}
34
+
35
+ HttpMessage::HttpMessage(const std::string &string) EXCEPT(InvalidMessage) { setString(string); }
36
+
37
+ std::string HttpMessage::toString() const {
38
+ std::string str;
39
+ return toString(str);
40
+ }
41
+
42
+ std::string &HttpMessage::toString(std::string &str) const {
43
+ str = m_root + getParameterString();
44
+ return str;
45
+ }
46
+
47
+ void HttpMessage::setString(const std::string &string) EXCEPT(InvalidMessage) {
48
+ clear();
49
+
50
+ std::string::size_type eolPos = string.find("\r\n");
51
+ if (eolPos == std::string::npos) {
52
+ throw InvalidMessage();
53
+ }
54
+ std::string line = string.substr(0, eolPos);
55
+ std::string::size_type getPos = line.find("GET ");
56
+ if (getPos != 0) {
57
+ throw InvalidMessage();
58
+ }
59
+ std::string::size_type httpPos = line.rfind("HTTP", std::string::npos);
60
+ if (httpPos == std::string::npos) {
61
+ throw InvalidMessage();
62
+ }
63
+
64
+ m_root = line.substr(getPos + 4, httpPos - 5);
65
+ std::string::size_type paramPos = m_root.find_first_of('?');
66
+ if (paramPos == std::string::npos) {
67
+ return;
68
+ }
69
+ std::string parameters = m_root.substr(paramPos, m_root.size() - paramPos);
70
+ m_root = m_root.substr(0, paramPos);
71
+ paramPos = 0;
72
+
73
+ while (paramPos != std::string::npos) {
74
+ std::string::size_type sepPos = parameters.find_first_of("=", paramPos);
75
+ if (sepPos == std::string::npos) {
76
+ break;
77
+ }
78
+ std::string::size_type tempPos = paramPos;
79
+ paramPos = parameters.find_first_of("&", paramPos + 1);
80
+ std::string key = parameters.substr(tempPos + 1, sepPos - tempPos - 1);
81
+ std::string value = parameters.substr(sepPos + 1, paramPos - sepPos - 1);
82
+ m_parameters[key] = value;
83
+ }
84
+ }
85
+
86
+ std::string HttpMessage::createResponse(int error, const std::string &text) {
87
+ std::string errorString;
88
+ switch (error) {
89
+ case 100:
90
+ errorString = "Continue";
91
+ break;
92
+ case 101:
93
+ errorString = "Switching Protocols";
94
+ break;
95
+ case 200:
96
+ errorString = "OK";
97
+ break;
98
+ case 201:
99
+ errorString = "Created";
100
+ break;
101
+ case 202:
102
+ errorString = "Accepted";
103
+ break;
104
+ case 203:
105
+ errorString = "Non-Authoritative Information";
106
+ break;
107
+ case 204:
108
+ errorString = "No Content";
109
+ break;
110
+ case 205:
111
+ errorString = "Reset Content";
112
+ break;
113
+ case 206:
114
+ errorString = "Partial Content";
115
+ break;
116
+ case 300:
117
+ errorString = "Multiple Choices";
118
+ break;
119
+ case 301:
120
+ errorString = "Moved Permanently";
121
+ break;
122
+ case 302:
123
+ errorString = "Found";
124
+ break;
125
+ case 303:
126
+ errorString = "See Other";
127
+ break;
128
+ case 304:
129
+ errorString = "Not Modified";
130
+ break;
131
+ case 305:
132
+ errorString = "Use Proxy";
133
+ break;
134
+ case 307:
135
+ errorString = "Temporary Redirect";
136
+ break;
137
+ case 400:
138
+ errorString = "Bad Request";
139
+ break;
140
+ case 401:
141
+ errorString = "Unauthorized";
142
+ break;
143
+ case 402:
144
+ errorString = "Payment Required";
145
+ break;
146
+ case 403:
147
+ errorString = "Forbidden";
148
+ break;
149
+ case 404:
150
+ errorString = "Not Found";
151
+ break;
152
+ case 405:
153
+ errorString = "Method Not Allowed";
154
+ break;
155
+ case 406:
156
+ errorString = "Not Acceptable";
157
+ break;
158
+ case 407:
159
+ errorString = "Proxy Authentication Required";
160
+ break;
161
+ case 408:
162
+ errorString = "Request Timeout";
163
+ break;
164
+ case 409:
165
+ errorString = "Conflict";
166
+ break;
167
+ case 410:
168
+ errorString = "Gone";
169
+ break;
170
+ case 411:
171
+ errorString = "Length Required";
172
+ break;
173
+ case 412:
174
+ errorString = "Precondition Failed";
175
+ break;
176
+ case 413:
177
+ errorString = "Request Entity Too Large";
178
+ break;
179
+ case 414:
180
+ errorString = "Request-URI Too Large";
181
+ break;
182
+ case 415:
183
+ errorString = "Unsupported Media Type";
184
+ break;
185
+ case 416:
186
+ errorString = "Requested Range Not Satisfiable";
187
+ break;
188
+ case 417:
189
+ errorString = "Expectation Failed";
190
+ break;
191
+ case 500:
192
+ errorString = "Internal Server Error";
193
+ break;
194
+ case 501:
195
+ errorString = "Not Implemented";
196
+ break;
197
+ case 502:
198
+ errorString = "Bad Gateway";
199
+ break;
200
+ case 503:
201
+ errorString = "Service Unavailable";
202
+ break;
203
+ case 504:
204
+ errorString = "Gateway Timeout";
205
+ break;
206
+ case 505:
207
+ errorString = "HTTP Version not supported";
208
+ break;
209
+ default:
210
+ errorString = "Unknown";
211
+ }
212
+
213
+ std::stringstream response;
214
+ response << "HTTP/1.1 " << error << " " << errorString << "\r\n"
215
+ << "Server: QuickFIX" << "\r\n"
216
+ << "Content-Type: text/html; charset=iso-8859-1" << "\r\n\r\n"
217
+ << "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">";
218
+
219
+ if (error < 200 || error >= 300) {
220
+ response << "<HTML><HEAD><TITLE>" << error << " " << errorString << "</TITLE></HEAD><BODY>"
221
+ << "<H1>" << error << " " << errorString << "</H1>" << text << "</BODY></HTML>";
222
+ } else {
223
+ response << text;
224
+ }
225
+
226
+ return response.str();
227
+ }
228
+
229
+ } // namespace FIX
@@ -0,0 +1,112 @@
1
+ /* -*- C++ -*- */
2
+
3
+ /****************************************************************************
4
+ ** Copyright (c) 2001-2014
5
+ **
6
+ ** This file is part of the QuickFIX FIX Engine
7
+ **
8
+ ** This file may be distributed under the terms of the quickfixengine.org
9
+ ** license as defined by quickfixengine.org and appearing in the file
10
+ ** LICENSE included in the packaging of this file.
11
+ **
12
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
+ **
15
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
16
+ **
17
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
18
+ ** not clear to you.
19
+ **
20
+ ****************************************************************************/
21
+
22
+ #ifndef FIX_HTTPMESSAGE
23
+ #define FIX_HTTPMESSAGE
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4786)
27
+ #endif
28
+
29
+ #include "Exceptions.h"
30
+ #include <map>
31
+
32
+ namespace FIX {
33
+ /**
34
+ * HTTP Message that implemented GET functionality
35
+ */
36
+ class HttpMessage {
37
+ public:
38
+ typedef std::map<std::string, std::string> Parameters;
39
+
40
+ HttpMessage();
41
+
42
+ /// Construct a message from a string
43
+ HttpMessage(const std::string &string) EXCEPT(InvalidMessage);
44
+
45
+ HttpMessage(const HttpMessage &copy) {
46
+ m_root = copy.m_root;
47
+ m_parameters = copy.m_parameters;
48
+ }
49
+
50
+ public:
51
+ /// Get a string representation of the message
52
+ std::string toString() const;
53
+ /// Get a string representation without making a copy
54
+ std::string &toString(std::string &) const;
55
+
56
+ void setString(const std::string &string) EXCEPT(InvalidMessage);
57
+
58
+ void clear() {
59
+ #if defined(_MSC_VER) && _MSC_VER < 1300
60
+ m_root = "";
61
+ #else
62
+ m_root.clear();
63
+ #endif
64
+ m_parameters.clear();
65
+ }
66
+
67
+ const std::string &getRootString() const { return m_root; }
68
+
69
+ const std::string getParameterString() const {
70
+ std::string result;
71
+ for (Parameters::const_iterator i = m_parameters.begin(); i != m_parameters.end(); ++i) {
72
+ result += (i == m_parameters.begin()) ? "?" : "&";
73
+ result += i->first + "=" + i->second;
74
+ }
75
+ return result;
76
+ }
77
+
78
+ const Parameters &getParameters() const { return m_parameters; }
79
+
80
+ bool hasParameter(const std::string &key) const {
81
+ Parameters::const_iterator find = m_parameters.find(key);
82
+ return find != m_parameters.end();
83
+ }
84
+
85
+ const std::string &getParameter(const std::string &key) const EXCEPT(std::logic_error) {
86
+ Parameters::const_iterator find = m_parameters.find(key);
87
+ if (find == m_parameters.end()) {
88
+ throw std::logic_error("Parameter " + key + " not found");
89
+ }
90
+ return find->second;
91
+ }
92
+
93
+ void addParameter(const std::string &key, const std::string &value) { m_parameters[key] = value; }
94
+
95
+ void removeParameter(const std::string &key) { m_parameters.erase(key); }
96
+
97
+ static std::string createResponse(int error = 0, const std::string &text = "");
98
+
99
+ private:
100
+ std::string m_root;
101
+ Parameters m_parameters;
102
+ };
103
+ /*! @} */
104
+
105
+ inline std::ostream &operator<<(std::ostream &stream, const HttpMessage &message) {
106
+ std::string str;
107
+ stream << message.toString(str);
108
+ return stream;
109
+ }
110
+ } // namespace FIX
111
+
112
+ #endif // FIX_HTTPMESSAGE
@@ -0,0 +1,49 @@
1
+ /****************************************************************************
2
+ ** Copyright (c) 2001-2014
3
+ **
4
+ ** This file is part of the QuickFIX FIX Engine
5
+ **
6
+ ** This file may be distributed under the terms of the quickfixengine.org
7
+ ** license as defined by quickfixengine.org and appearing in the file
8
+ ** LICENSE included in the packaging of this file.
9
+ **
10
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12
+ **
13
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
14
+ **
15
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
16
+ ** not clear to you.
17
+ **
18
+ ****************************************************************************/
19
+
20
+ #ifdef _MSC_VER
21
+ #include "stdafx.h"
22
+ #else
23
+ #include "config.h"
24
+ #endif
25
+
26
+ #include "HttpParser.h"
27
+ #include "Utility.h"
28
+ #include <algorithm>
29
+
30
+ namespace FIX {
31
+ bool HttpParser::readHttpMessage(std::string &str) EXCEPT(MessageParseError) {
32
+ std::string::size_type pos = 0;
33
+
34
+ if (m_buffer.length() < 4) {
35
+ return false;
36
+ }
37
+ pos = m_buffer.find("\r\n\r\n");
38
+ if (m_buffer.length() > 2048) {
39
+ throw MessageParseError();
40
+ }
41
+ if (pos == std::string::npos) {
42
+ return false;
43
+ }
44
+ str.assign(m_buffer, 0, pos + 4);
45
+ m_buffer.erase(0, pos + 4);
46
+
47
+ return true;
48
+ }
49
+ } // namespace FIX
@@ -0,0 +1,49 @@
1
+ /* -*- C++ -*- */
2
+
3
+ /****************************************************************************
4
+ ** Copyright (c) 2001-2014
5
+ **
6
+ ** This file is part of the QuickFIX FIX Engine
7
+ **
8
+ ** This file may be distributed under the terms of the quickfixengine.org
9
+ ** license as defined by quickfixengine.org and appearing in the file
10
+ ** LICENSE included in the packaging of this file.
11
+ **
12
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14
+ **
15
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
16
+ **
17
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
18
+ ** not clear to you.
19
+ **
20
+ ****************************************************************************/
21
+
22
+ #ifndef FIX_HTTPPARSER_H
23
+ #define FIX_HTTPPARSER_H
24
+
25
+ #ifdef _MSC_VER
26
+ #pragma warning(disable : 4503 4355 4786 4290)
27
+ #endif
28
+
29
+ #include "Exceptions.h"
30
+ #include <iostream>
31
+ #include <string>
32
+
33
+ namespace FIX {
34
+ /// Parses HTTP messages off an input stream.
35
+ class HttpParser {
36
+ public:
37
+ HttpParser() {}
38
+ ~HttpParser() {}
39
+
40
+ bool readHttpMessage(std::string &str) EXCEPT(MessageParseError);
41
+
42
+ void addToStream(const char *str, size_t len) { m_buffer.append(str, len); }
43
+ void addToStream(const std::string &str) { m_buffer.append(str); }
44
+
45
+ private:
46
+ std::string m_buffer;
47
+ };
48
+ } // namespace FIX
49
+ #endif // FIX_HTTPPARSER_H
@@ -0,0 +1,152 @@
1
+ /****************************************************************************
2
+ ** Copyright (c) 2001-2014
3
+ **
4
+ ** This file is part of the QuickFIX FIX Engine
5
+ **
6
+ ** This file may be distributed under the terms of the quickfixengine.org
7
+ ** license as defined by quickfixengine.org and appearing in the file
8
+ ** LICENSE included in the packaging of this file.
9
+ **
10
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
11
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
12
+ **
13
+ ** See http://www.quickfixengine.org/LICENSE for licensing information.
14
+ **
15
+ ** Contact ask@quickfixengine.org if any conditions of this licensing are
16
+ ** not clear to you.
17
+ **
18
+ ****************************************************************************/
19
+
20
+ #ifdef _MSC_VER
21
+ #include "stdafx.h"
22
+ #else
23
+ #include "config.h"
24
+ #endif
25
+
26
+ #include "HttpConnection.h"
27
+ #include "HttpServer.h"
28
+ #include "Settings.h"
29
+ #include "Utility.h"
30
+
31
+ namespace FIX {
32
+ Mutex HttpServer::s_mutex;
33
+ int HttpServer::s_count = 0;
34
+ HttpServer *HttpServer::s_pServer = 0;
35
+
36
+ void HttpServer::startGlobal(const SessionSettings &s) EXCEPT(ConfigError, RuntimeError) {
37
+ Locker l(s_mutex);
38
+
39
+ if (!s.get().has(HTTP_ACCEPT_PORT)) {
40
+ return;
41
+ }
42
+
43
+ s_count += 1;
44
+ if (!s_pServer) {
45
+ s_pServer = new HttpServer(s);
46
+ s_pServer->start();
47
+ }
48
+ }
49
+
50
+ void HttpServer::stopGlobal() {
51
+ Locker l(s_mutex);
52
+
53
+ s_count -= 1;
54
+ if (!s_count && s_pServer) {
55
+ s_pServer->stop();
56
+ delete s_pServer;
57
+ s_pServer = 0;
58
+ }
59
+ }
60
+
61
+ HttpServer::HttpServer(const SessionSettings &settings) EXCEPT(ConfigError)
62
+ : m_pServer(0),
63
+ m_settings(settings),
64
+ m_threadid(0),
65
+ m_port(0),
66
+ m_stop(false) {}
67
+
68
+ void HttpServer::onConfigure(const SessionSettings &s) EXCEPT(ConfigError) {
69
+ m_port = s.get().getInt(HTTP_ACCEPT_PORT);
70
+ }
71
+
72
+ void HttpServer::onInitialize(const SessionSettings &s) EXCEPT(RuntimeError) {
73
+ try {
74
+ m_pServer = new SocketServer(1);
75
+ m_pServer->add(m_port, true, false, 0, 0);
76
+ } catch (std::exception &) {
77
+ throw RuntimeError("Unable to create, bind, or listen to port " + IntConvertor::convert((unsigned short)m_port));
78
+ }
79
+ }
80
+
81
+ void HttpServer::start() EXCEPT(ConfigError, RuntimeError) {
82
+ m_stop = false;
83
+ onConfigure(m_settings);
84
+ onInitialize(m_settings);
85
+
86
+ if (!thread_spawn(&startThread, this, m_threadid)) {
87
+ throw RuntimeError("Unable to spawn thread");
88
+ }
89
+ }
90
+
91
+ void HttpServer::stop() {
92
+ if (m_stop) {
93
+ return;
94
+ }
95
+ m_stop = true;
96
+ onStop();
97
+
98
+ if (m_threadid) {
99
+ thread_join(m_threadid);
100
+ }
101
+ m_threadid = 0;
102
+ }
103
+
104
+ void HttpServer::onStart() {
105
+ while (!m_stop && m_pServer && m_pServer->block(*this)) {}
106
+
107
+ if (!m_pServer) {
108
+ return;
109
+ }
110
+
111
+ m_pServer->close();
112
+ delete m_pServer;
113
+ m_pServer = 0;
114
+ }
115
+
116
+ bool HttpServer::onPoll() {
117
+ if (!m_pServer || m_stop) {
118
+ return false;
119
+ }
120
+
121
+ m_pServer->block(*this, true);
122
+ return true;
123
+ }
124
+
125
+ void HttpServer::onStop() {}
126
+
127
+ void HttpServer::onConnect(SocketServer &server, socket_handle a, socket_handle s) {
128
+ if (!socket_isValid(s)) {
129
+ return;
130
+ }
131
+ HttpConnection connection(s);
132
+ while (connection.read()) {}
133
+ m_pServer->getMonitor().drop(s);
134
+ }
135
+
136
+ void HttpServer::onWrite(SocketServer &server, socket_handle s) {}
137
+
138
+ bool HttpServer::onData(SocketServer &server, socket_handle s) { return true; }
139
+
140
+ void HttpServer::onDisconnect(SocketServer &, socket_handle s) {}
141
+
142
+ void HttpServer::onError(SocketServer &) {}
143
+
144
+ void HttpServer::onTimeout(SocketServer &) {}
145
+
146
+ THREAD_PROC HttpServer::startThread(void *p) {
147
+ HttpServer *pServer = static_cast<HttpServer *>(p);
148
+ pServer->onStart();
149
+ return 0;
150
+ }
151
+
152
+ } // namespace FIX