Mercurial > hg > orthanc
comparison OrthancFramework/Sources/HttpServer/HttpServer.cpp @ 4298:db3932f9660d
abi continued
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 05 Nov 2020 18:21:03 +0100 |
parents | 90f91b78d708 |
children | 6919242d2265 |
comparison
equal
deleted
inserted
replaced
4297:785a2713323e | 4298:db3932f9660d |
---|---|
1521 { | 1521 { |
1522 Stop(); | 1522 Stop(); |
1523 port_ = port; | 1523 port_ = port; |
1524 } | 1524 } |
1525 | 1525 |
1526 uint16_t HttpServer::GetPortNumber() const | |
1527 { | |
1528 return port_; | |
1529 } | |
1530 | |
1526 void HttpServer::Start() | 1531 void HttpServer::Start() |
1527 { | 1532 { |
1528 #if ORTHANC_ENABLE_MONGOOSE == 1 | 1533 #if ORTHANC_ENABLE_MONGOOSE == 1 |
1529 CLOG(INFO, HTTP) << "Starting embedded Web server using Mongoose"; | 1534 CLOG(INFO, HTTP) << "Starting embedded Web server using Mongoose"; |
1530 #elif ORTHANC_ENABLE_CIVETWEB == 1 | 1535 #elif ORTHANC_ENABLE_CIVETWEB == 1 |
1697 std::string encoded; | 1702 std::string encoded; |
1698 Toolbox::EncodeBase64(encoded, tag); | 1703 Toolbox::EncodeBase64(encoded, tag); |
1699 registeredUsers_.insert(encoded); | 1704 registeredUsers_.insert(encoded); |
1700 } | 1705 } |
1701 | 1706 |
1707 bool HttpServer::IsAuthenticationEnabled() const | |
1708 { | |
1709 return authentication_; | |
1710 } | |
1711 | |
1702 void HttpServer::SetSslEnabled(bool enabled) | 1712 void HttpServer::SetSslEnabled(bool enabled) |
1703 { | 1713 { |
1704 Stop(); | 1714 Stop(); |
1705 | 1715 |
1706 #if ORTHANC_ENABLE_SSL == 0 | 1716 #if ORTHANC_ENABLE_SSL == 0 |
1747 CLOG(WARNING, HTTP) << "You should disable HTTP keep alive, as you are using Mongoose"; | 1757 CLOG(WARNING, HTTP) << "You should disable HTTP keep alive, as you are using Mongoose"; |
1748 } | 1758 } |
1749 #endif | 1759 #endif |
1750 } | 1760 } |
1751 | 1761 |
1762 const std::string &HttpServer::GetSslCertificate() const | |
1763 { | |
1764 return certificate_; | |
1765 } | |
1766 | |
1752 | 1767 |
1753 void HttpServer::SetAuthenticationEnabled(bool enabled) | 1768 void HttpServer::SetAuthenticationEnabled(bool enabled) |
1754 { | 1769 { |
1755 Stop(); | 1770 Stop(); |
1756 authentication_ = enabled; | 1771 authentication_ = enabled; |
1757 } | 1772 } |
1758 | 1773 |
1774 bool HttpServer::IsSslEnabled() const | |
1775 { | |
1776 return ssl_; | |
1777 } | |
1778 | |
1759 void HttpServer::SetSslCertificate(const char* path) | 1779 void HttpServer::SetSslCertificate(const char* path) |
1760 { | 1780 { |
1761 Stop(); | 1781 Stop(); |
1762 certificate_ = path; | 1782 certificate_ = path; |
1763 } | 1783 } |
1764 | 1784 |
1785 bool HttpServer::IsRemoteAccessAllowed() const | |
1786 { | |
1787 return remoteAllowed_; | |
1788 } | |
1789 | |
1765 void HttpServer::SetSslTrustedClientCertificates(const char* path) | 1790 void HttpServer::SetSslTrustedClientCertificates(const char* path) |
1766 { | 1791 { |
1767 Stop(); | 1792 Stop(); |
1768 trustedClientCertificates_ = path; | 1793 trustedClientCertificates_ = path; |
1769 } | 1794 } |
1770 | 1795 |
1796 bool HttpServer::IsKeepAliveEnabled() const | |
1797 { | |
1798 return keepAlive_; | |
1799 } | |
1800 | |
1771 void HttpServer::SetRemoteAccessAllowed(bool allowed) | 1801 void HttpServer::SetRemoteAccessAllowed(bool allowed) |
1772 { | 1802 { |
1773 Stop(); | 1803 Stop(); |
1774 remoteAllowed_ = allowed; | 1804 remoteAllowed_ = allowed; |
1805 } | |
1806 | |
1807 bool HttpServer::IsHttpCompressionEnabled() const | |
1808 { | |
1809 return httpCompression_;; | |
1775 } | 1810 } |
1776 | 1811 |
1777 void HttpServer::SetHttpCompressionEnabled(bool enabled) | 1812 void HttpServer::SetHttpCompressionEnabled(bool enabled) |
1778 { | 1813 { |
1779 Stop(); | 1814 Stop(); |
1780 httpCompression_ = enabled; | 1815 httpCompression_ = enabled; |
1781 CLOG(WARNING, HTTP) << "HTTP compression is " << (enabled ? "enabled" : "disabled"); | 1816 CLOG(WARNING, HTTP) << "HTTP compression is " << (enabled ? "enabled" : "disabled"); |
1782 } | 1817 } |
1818 | |
1819 IIncomingHttpRequestFilter *HttpServer::GetIncomingHttpRequestFilter() const | |
1820 { | |
1821 return filter_; | |
1822 } | |
1783 | 1823 |
1784 void HttpServer::SetIncomingHttpRequestFilter(IIncomingHttpRequestFilter& filter) | 1824 void HttpServer::SetIncomingHttpRequestFilter(IIncomingHttpRequestFilter& filter) |
1785 { | 1825 { |
1786 Stop(); | 1826 Stop(); |
1787 filter_ = &filter; | 1827 filter_ = &filter; |
1792 { | 1832 { |
1793 Stop(); | 1833 Stop(); |
1794 exceptionFormatter_ = &formatter; | 1834 exceptionFormatter_ = &formatter; |
1795 } | 1835 } |
1796 | 1836 |
1837 IHttpExceptionFormatter *HttpServer::GetExceptionFormatter() | |
1838 { | |
1839 return exceptionFormatter_; | |
1840 } | |
1841 | |
1842 const std::string &HttpServer::GetRealm() const | |
1843 { | |
1844 return realm_; | |
1845 } | |
1846 | |
1847 void HttpServer::SetRealm(const std::string &realm) | |
1848 { | |
1849 realm_ = realm; | |
1850 } | |
1851 | |
1797 | 1852 |
1798 bool HttpServer::IsValidBasicHttpAuthentication(const std::string& basic) const | 1853 bool HttpServer::IsValidBasicHttpAuthentication(const std::string& basic) const |
1799 { | 1854 { |
1800 return registeredUsers_.find(basic) != registeredUsers_.end(); | 1855 return registeredUsers_.find(basic) != registeredUsers_.end(); |
1801 } | 1856 } |
1803 | 1858 |
1804 void HttpServer::Register(IHttpHandler& handler) | 1859 void HttpServer::Register(IHttpHandler& handler) |
1805 { | 1860 { |
1806 Stop(); | 1861 Stop(); |
1807 handler_ = &handler; | 1862 handler_ = &handler; |
1863 } | |
1864 | |
1865 bool HttpServer::HasHandler() const | |
1866 { | |
1867 return handler_ != NULL; | |
1808 } | 1868 } |
1809 | 1869 |
1810 | 1870 |
1811 IHttpHandler& HttpServer::GetHandler() const | 1871 IHttpHandler& HttpServer::GetHandler() const |
1812 { | 1872 { |
1828 | 1888 |
1829 Stop(); | 1889 Stop(); |
1830 threadsCount_ = threads; | 1890 threadsCount_ = threads; |
1831 | 1891 |
1832 CLOG(INFO, HTTP) << "The embedded HTTP server will use " << threads << " threads"; | 1892 CLOG(INFO, HTTP) << "The embedded HTTP server will use " << threads << " threads"; |
1893 } | |
1894 | |
1895 unsigned int HttpServer::GetThreadsCount() const | |
1896 { | |
1897 return threadsCount_; | |
1833 } | 1898 } |
1834 | 1899 |
1835 | 1900 |
1836 void HttpServer::SetTcpNoDelay(bool tcpNoDelay) | 1901 void HttpServer::SetTcpNoDelay(bool tcpNoDelay) |
1837 { | 1902 { |
1839 tcpNoDelay_ = tcpNoDelay; | 1904 tcpNoDelay_ = tcpNoDelay; |
1840 CLOG(INFO, HTTP) << "TCP_NODELAY for the HTTP sockets is set to " | 1905 CLOG(INFO, HTTP) << "TCP_NODELAY for the HTTP sockets is set to " |
1841 << (tcpNoDelay ? "true" : "false"); | 1906 << (tcpNoDelay ? "true" : "false"); |
1842 } | 1907 } |
1843 | 1908 |
1909 bool HttpServer::IsTcpNoDelay() const | |
1910 { | |
1911 return tcpNoDelay_; | |
1912 } | |
1913 | |
1844 | 1914 |
1845 void HttpServer::SetRequestTimeout(unsigned int seconds) | 1915 void HttpServer::SetRequestTimeout(unsigned int seconds) |
1846 { | 1916 { |
1847 if (seconds == 0) | 1917 if (seconds == 0) |
1848 { | 1918 { |
1852 | 1922 |
1853 Stop(); | 1923 Stop(); |
1854 requestTimeout_ = seconds; | 1924 requestTimeout_ = seconds; |
1855 CLOG(INFO, HTTP) << "Request timeout in the HTTP server is set to " << seconds << " seconds"; | 1925 CLOG(INFO, HTTP) << "Request timeout in the HTTP server is set to " << seconds << " seconds"; |
1856 } | 1926 } |
1927 | |
1928 unsigned int HttpServer::GetRequestTimeout() const | |
1929 { | |
1930 return requestTimeout_; | |
1931 } | |
1932 | |
1933 | |
1934 #if ORTHANC_ENABLE_PUGIXML == 1 | |
1935 HttpServer::WebDavBuckets& HttpServer::GetWebDavBuckets() | |
1936 { | |
1937 return webDavBuckets_; | |
1938 } | |
1939 #endif | |
1857 | 1940 |
1858 | 1941 |
1859 #if ORTHANC_ENABLE_PUGIXML == 1 | 1942 #if ORTHANC_ENABLE_PUGIXML == 1 |
1860 void HttpServer::Register(const std::vector<std::string>& root, | 1943 void HttpServer::Register(const std::vector<std::string>& root, |
1861 IWebDavBucket* bucket) | 1944 IWebDavBucket* bucket) |