HttpConnection.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*- C++ -*- */
  2. /****************************************************************************
  3. ** Copyright (c) 2001-2014
  4. **
  5. ** This file is part of the QuickFIX FIX Engine
  6. **
  7. ** This file may be distributed under the terms of the quickfixengine.org
  8. ** license as defined by quickfixengine.org and appearing in the file
  9. ** LICENSE included in the packaging of this file.
  10. **
  11. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  12. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. **
  14. ** See http://www.quickfixengine.org/LICENSE for licensing information.
  15. **
  16. ** Contact ask@quickfixengine.org if any conditions of this licensing are
  17. ** not clear to you.
  18. **
  19. ****************************************************************************/
  20. #ifndef FIX_HTTPCONNECTION_H
  21. #define FIX_HTTPCONNECTION_H
  22. #ifdef _MSC_VER
  23. #pragma warning( disable : 4503 4355 4786 4290 )
  24. #endif
  25. #include "HttpParser.h"
  26. #include <stdio.h>
  27. namespace FIX
  28. {
  29. class HttpMessage;
  30. /// Encapsulates a HTTP socket file descriptor
  31. class HttpConnection
  32. {
  33. public:
  34. HttpConnection( int s );
  35. int getSocket() const { return m_socket; }
  36. bool read();
  37. private:
  38. bool readMessage( std::string& msg ) throw( SocketRecvFailed );
  39. void processStream();
  40. void processRequest( const HttpMessage& );
  41. void processRoot( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  42. void processResetSessions( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  43. void processRefreshSessions( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  44. void processEnableSessions( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  45. void processDisableSessions( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  46. void processSession( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  47. void processResetSession( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  48. void processRefreshSession( const HttpMessage&, std::stringstream& h, std::stringstream& b );
  49. void showToggle
  50. ( std::stringstream& s, const std::string& name, bool value, const std::string& url );
  51. void showRow
  52. ( std::stringstream& s, const std::string& name, bool value, const std::string& url = "" );
  53. void showRow
  54. ( std::stringstream& s, const std::string& name, const std::string& value, const std::string& url = "" );
  55. void showRow
  56. ( std::stringstream& s, const std::string& name, int value, const std::string& url = "" );
  57. bool send( const std::string& );
  58. void disconnect( int error = 0 );
  59. int m_socket;
  60. char m_buffer[BUFSIZ];
  61. HttpParser m_parser;
  62. fd_set m_fds;
  63. };
  64. }
  65. #endif