Commit Graph

365 Commits

Author SHA1 Message Date
Matej Kenda
7addcfbc81 fix: Resolve compiler warnings across multiple modules 2025-12-17 18:06:59 +01:00
Matej Kenda
a6648ee8c3 Foundation simplifications with modern cpp (#5086)
* enh(Logger): simplified logging macros.

* enh(Delegate): Simplify code with constexpr and std::conditional_t.

* enh(NumericString): Simplify code with constexpr and std::is_signed_v.

* enh(MetaProgramming): Simplify code with C++17 equivalents.

* enh(Tuple): Simplify code with C++17 equivalents.

* enh(TypeList): Remove metaprogramming features that are not used.

* enh(Modules): Remove obsolete Foundation functionality

* enh(Foundation): Compile and run deprecated functionality only when POCO_TEST_DEPRECATED is enabled. Update comments for deprecated functionality.

* fix(Modules): Add missing conditional forward declarations for Foundation.
2025-12-16 07:53:45 +01:00
Matej Kenda
227f84fb8b fix(Net): Add POCO_HAS_UNIX_SOCKET guards to fix build without Unix sockets #5064 2025-12-16 06:50:21 +01:00
Copilot
b35f44c552 Fix WebSocket sendFrame delay by enabling TCP_NODELAY (#5077)
* Initial plan

* Fix WebSocket sendFrame delay by enabling TCP_NODELAY

- Enable TCP_NODELAY in WebSocketImpl constructor to prevent Nagle's algorithm
  from buffering small WebSocket frames
- Add check to skip TCP_NODELAY for Unix domain sockets
- Add documentation about TCP_NODELAY behavior to WebSocket class
- Tested with existing WebSocket test suite - all tests pass

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

* Address code review feedback

- Avoid unnecessary SocketAddress object construction by calling family() directly
- Use specific exception type (Poco::Exception) instead of catch-all

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

* Refine exception handling for TCP_NODELAY configuration

- Catch specific exception types (NetException, IOException, InvalidArgumentException)
  instead of broad Poco::Exception
- Improve error handling comments for clarity

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

* Consolidate exception handling for better maintainability

- Combine catch blocks since all exceptions are handled identically
- Improve code clarity with more descriptive comments

Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aleks-f <2429093+aleks-f@users.noreply.github.com>
2025-12-09 02:05:39 +01:00
Matej Kenda
8a4a2955d5 Use nullptr in C++ code (solves #4348) (#5043)
* chore(CppParser): 0, NULL --> nullptr

* chore(Crypto): 0, NULL --> nullptr

* chore(DNSSD): 0, NULL --> nullptr

* chore(Encodings): 0, NULL --> nullptr

* chore(CppUnit): Correct indentation.

* chore(Foundation): 0, NULL --> nullptr

* chore(CMake): Always warn about wrong nullptr usage when compiling with GCC or CLang

* chore(Net): 0, NULL --> nullptr

* chore(Foundation): 0, NULL --> nullptr

* chore(Data): 0, NULL --> nullptr

* chore(macOS): 0, NULL --> nullptr

* chore(XML): 0, NULL --> nullptr

* chore(Zip): 0, NULL --> nullptr

* chore(Util): 0, NULL --> nullptr

* chore(Net/NetSSL): 0, NULL --> nullptr

* chore(Bonjour): 0, NULL --> nullptr

* chore(MongoDB, Redis): 0, NULL --> nullptr

* chore(Poco): 0, NULL --> nullptr

* chore(Win32): 0, NULL --> nullptr

* chore(CMake): Only warn about nullptr when verbose warnings are enabled.

* Potential fix for code scanning alert no. 1634: Guarded Free

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* chore(Net): Fix warning reported by gitlab.

* chore(gitlab CI): attempt to clean to gain disk space on the runner.

* chore(gitlab CI): Run build with  --parallel 4, correct docker cleanup.

---------

Co-authored-by: Aleksandar Fabijanic <aleks-f@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2025-10-30 15:20:53 +01:00
sky92zwq
68616db653 Add an implementation of reactor http server (#4946)
* reactor http server

* fix

* test logic

* add reactor server session , use buf to cache socket buffer

* add reactor example

* fix: nodelay, otherwise ack will be after 50 ms

* tcp reactor server support multi listener

* fix: tcp reactor connection lifetime about socket

* feat: add tcp reactor params

* format

* check http reqeust complete, dynamic size buffer in reactor

* remove try catch

* remove debug logger

* remove debug logger

* fix: should not pop in destructor

* delete useless

* remove cankeepalive temporarily, optimize check complete req

* coding style

* coding style

* reactor server session unit test

* http reactor time server add delay param

* optimize switch case, and pop completed msg in destructor

* refactor reactor server session

* fix: check completed request when headers are in lower case like oha, add unit tests

* fix auto_ptr compile error, remove logger and coding style

* compile and tests fix, add reactor obj in makefile and vcxproj

* compile and tests fix in win, add reactor sample vcxproj

* compile and tests fix in macos when visibility is hidden
2025-09-30 14:41:30 +02:00
Miko
041e7feeb7 Add support for modules (#4999)
* Add support for modules

* Use "" for inclusion

* Fix missing includes on Poco.Data module

* Add PDF and SevenZip modules, and match modules to build macros

* Add CI test

* Add missing link libraries in CMake

* Add remaining libraries DNSSD, CppParser and CppUnit. Changed some static declarations to inline to export

* We also need to forward the ENABLE_NETSSL_* macros

* Update CMakeLists files

* Add samples as requested, with DateTime and URI test for example

* Fix POCO_MODULES_INSTALL macro

* chore(CMake): Combine install macro for libraries and C++ modules into one macro.

* Apply testsuite changes and address include directories concerns

* Restore accidentally deleted build files

* Mistakenly added a file generated by CMake, removed.

---------

Co-authored-by: Matej Kenda <matejken@gmail.com>
2025-09-19 19:46:36 +02:00
Matej Kenda
dbc800083e fix(Net): Add missing Net_API to Poco::Net::htmlize(const std::string&); 2025-09-12 11:00:16 +02:00
Matej Kenda
e6f661d313 chore(deprecated): Describe deprecation reasons and alternatives. 2025-09-11 09:25:01 +02:00
Günter Obiltschnig
a029be8997 Support for RFC 6265 cookies (#4982)
* enh(Net): Support RFC 6265 cookies (#4518)

* fix(HTTPCookie): remove _expires field
2025-08-08 13:42:10 +02:00
Matej Kenda
735e174d90 Async notification center (dispatch notifications asynchronously) (#4957) 2025-06-12 21:12:57 +02:00
Günter Obiltschnig
a0822e02ca fix(Net): A SEGV at Net/src/MultipartReader.cpp:164:1 #4915 2025-04-15 22:11:47 +02:00
Jonas Bülow
d020166423 Fix warning deprecated-enum-enum-conversion on clang 2025-04-09 16:12:14 +02:00
Aleksandar Fabijanic
eb94de03a6 fix(TCPServer): continues to accept connections after stop() #4892 (#4896)
* fix(TCPServer): continues to accept connections after stop() #4892

* fix(TCPServer): first attempt to silence TSAN #4892

* fix(TCPServer): check stopped status after poll; add TCPServerFactory::stop() and allow factory to return nullptr on connection creation request #4892

* fix(TCPServer): initialize factory stopped flag #4892

* revert(SocketImpl): atomic sock fd
2025-03-12 22:15:19 +01:00
Günter Obiltschnig
f32e3d0b90 enh(Net): SocketImpl::sendFile() sends entire contents by repeatedly calling sendfile() if necessary 2025-02-09 16:03:51 +01:00
Günter Obiltschnig
66c1d30bb4 enh(Net): StreamSocket::sendFile() takes additional count parameter 2025-02-08 12:57:24 +01:00
Günter Obiltschnig
13029fb524 fix(Net): fix SocketImpl::sendFile() #4831 2025-02-07 18:06:14 +01:00
Günter Obiltschnig
5cab3be5c4 enh(Net): add HTTPBufferPoolAllocator::pool() to get read-only access to the underlying MemoryPool 2025-02-03 09:33:52 +01:00
Günter Obiltschnig
5652837b8f Merge pull request #4838 from d3matt/odd_nonblocking_receive_incorrect_mask
fix(Net) bad mask with odd number of bytes
2025-01-08 19:14:41 +01:00
Lara Dzivdzanovic
336e0e802f enh(SocketReactor): Add start() method #4833 (#4835) 2025-01-08 15:48:58 +01:00
Matthew Stoltenberg
0cc3ab4d13 fix(Net) bad mask with odd number of bytes
Receiving an odd number of bytes in non-blocking mode results in using the wrong bytes to unmask the payload. Keep track of the number of payload bytes that have been unmasked.
2025-01-06 16:57:25 -07:00
Günter Obiltschnig
854d8c89d6 enh(Net): Poco::Net::HTTPResponse: add replaceCookie() and removeCookie() #4825 2024-12-19 10:46:06 +01:00
Günter Obiltschnig
1811f2f35c fix(NetSSL): shutdown behavior 2024-11-28 08:19:45 +01:00
Matej Kenda
76ea8c74c8 enh(C++17): Net: Modernisation of socket class declarations. 2024-11-19 21:45:40 +01:00
Matej Kenda
efb0745efc enh(SocketReactor): Introduce protected accessors to private members to be used in derived classes. 2024-11-19 21:45:40 +01:00
Milan Tepic
64d8777a0e feat(WindowsBuild): customizable path to include for pocoNetworkInitializer #4769 2024-11-19 16:40:51 +01:00
Günter Obiltschnig
2815ea45a9 enh(Net): add PollSet::size(); mark PollSet::count() as deprecated 2024-11-17 22:16:52 +01:00
Günter Obiltschnig
63b4bfd8ba chore(WebSocket): docs 2024-11-16 18:42:38 +01:00
Günter Obiltschnig
cedd086362 feat(Net): Non-blocking WebSocket #4773 2024-11-16 16:49:50 +01:00
Günter Obiltschnig
42ccb0d96d enh(Net): SMTPClientSession: replace bare newlines in message content with CRLF (#4689) 2024-09-26 11:16:36 +02:00
Alexander B
710c2a41f3 Using native sendfile from OS for HttpServer (#4351)
* add possibility to use native sendFile from OS for HttpServerResponse
add option POCO_USE_SENDFILE_FOR_HTTPSERVER, default - OFF
add test for HttpServer - testFile
add define fro Config.h POCO_USE_SENDFILE_FOR_HTTPSERVER

* my fail, be carefull with macro and brackets

* replace option POCO_USE_SENDFILE_FOR_HTTPSERVER with compiletime
detected macro POCO_HAVE_SENDFILE
replace types for sendFile with platform depended
wrap possibility of using sendFile with macro, if sendFile doesn't exist
in OS, then all methods don't exist

* remove option POCO_USE_SENDFILE_FOR_HTTPSERVER from ci.yml

* wrap testSendFile in the suite with define POCO_HAVE_SENDFILE

* try fix compile problem with emscripten

* oh, emscripten again

* fix logical error in testSendFile

* fix problem with cmake-specific macro when usinf make-project

* revert types from platform depended to Poco::Int64 and Poco::UInt64
for sendfile
2024-09-01 20:45:33 +02:00
Étienne Dupuis
63bed8c8d3 Use Int64 for TcpServerDispatcher::totalConnections(), to prevent overflow 2024-08-26 16:06:47 +02:00
Matej Kenda
f24547cdcf enh(Poco): Mark deprecated functionality with C++ attributes and resolve internal usage of deprecated functions (#4551)
* enh(poco): Replace deprecated comments with C++ deprecated attribute.

* enh(Poco): Replace some deprecated functionality in Poco sources. (#4426)

* enh(Poco): Replace more deprecated functionality in Poco sources. (#4426)

* fix(CMake): Variable BUILD_SHARED_LIBS must be defined properly to create valid binaries.

* enh: Code improvements done while resolving deprecated functionality (#4426)

* Un-deprecate LocalDateTme (#4426)

* enh(Poco): Replace usage of deprecated functionality with other functions/classes (#4426)

* chore(SSL): temporarily un-deprecate SSL-related functionality (#4426)

* chore(SSL): temporarily un-deprecate old MongoDB protocol functionality (#4426)

* enh(Poco): Minor Hash improvements (#4426)

* enh(Foundation): Compile deprecated hash tests only when POCO_TEST_DEPRECATED is enabled (#4426)

* enh(Net): Compile deprecated Socket::select functionality only when POCO_TEST_DEPRECATED is enabled (#4426)

* enh(Bonjour): Replace deprecated Socket::select with PollSet (#4426)

* enh(Poco): Introduce POCO_DEPRECATED macro to have the ability to disable deprecation warnings in applications (#4426)

* test(ODBC): add few asserts to testStoredProcedureDynamicVar

* fix(ODBC): rename DynamicAny -> DynamicVar in tests

* fix(ODBC): make Dignostics static members inline to prevent explicit instantiation warnings on windows

---------

Co-authored-by: Alex Fabijanic <alex@pocoproject.org>
2024-07-29 08:37:35 +02:00
Günter Obiltschnig
c6249d9b3f enh(Net): clear out stored credentials 2024-06-11 12:19:52 +02:00
Günter Obiltschnig
401bec5010 style 2024-04-03 07:26:23 +02:00
zhuzeitou
3496e47475 Optimize Net module for Android (#4517)
* epoll is available on Android

* <ifaddrs.h> is introduced in android-24
2024-04-02 19:03:41 +02:00
Andrew Auclair
47c4f073e6 Moving operator<< and operator>> overloads into the Poco::Net namespace. (#4491) 2024-03-28 19:43:14 +01:00
Nicolau Leal Werneck
a5b3c84874 Documentation fixes on DatagramSocket.h and Socket.h (#4489)
* Update DatagramSocket.h

`connect cannot()` -> `connect() cannot`

* Update Socket.h

typo on `setReceiveTiemout`
2024-03-11 10:27:28 +01:00
Matej Kenda
c624b27878 fix(HostEntry): preserve order of addresses and aliases (fixes #3807) 2024-02-28 16:49:26 +01:00
Alex Fabijanic
30a0a06bac chore(ParallelSocketAcceptor): remove unnecessary include and using from header 2024-02-16 01:00:19 +01:00
Jesse Hoogervorst
5bc04f4c4a Implemented automated network library initialization for Windows MinGW targets (#4402)
* Implemented automated network library initialization for Windows MinGW/GCC targets

* Using POCO_COMPILER_MINGW instead of __GNUC__

---------

Co-authored-by: Jesse Hoogervorst <jesse@deltaxlab.com>
2024-01-17 14:51:23 +01:00
Aleksandar Fabijanic
64dbfab0fa 4398 dont install cppunit (#4399)
* chore(SingleSocketPoller): spelling

* fix(CppUnit): do not install #4398

* fix(DataTest): do not install #4398
2024-01-16 00:03:33 +01:00
Alex Fabijanic
9c7cba6d6c backport leftover 1.12 changes 2023-12-22 20:22:33 +01:00
Kari Argillander
bf3c519183 Fix some issues found with clang-tidy (#4353)
* directoryiterator: Fix missing inline

Add missing inline to inline function.

This was found with clang-tidy check:  misc-definitions-in-headers

* Convert deprecated throw() to noexcept

throw() has been deprecated in standar in C++17. It has been removed in
C++20. Code still compiles but let's just define these at those should
be.

These where found with clang-tidy check: modernize-use-noexcept

* Fix unnecessary copy initializations

Clang-tidy did find these with check:

  performance-unnecessary-copy-initialization

* Fix some strings not references

Looks like these are just missing reference marks.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2023-12-17 16:55:30 +01:00
Matej Kenda
214b54460e mingw 11: fixes to compile common libraries 2023-12-14 19:02:11 +01:00
Kari Argillander
708a5d8307 RFC: Remove Windows CE support (#4342)
* Remove _WIN32_WCE macro

Poco now use C++17 and Windows CE does not support it and VS2017 does
also not support it so we can just remove Windows CE code. First remove
all macro usages from our own files.

* Remove WinCE support from build files

Poco now use C++17 and Windows CE does not support it and VS2017 does
also not support it so we can just remove Windows CE code. Remove all
references from build systems / scripts.

* Remove Windows CE related source and header files

Poco now use C++17 and Windows CE does not support it and VS2017 does
also not support it so we can just remove Windows CE code. First remove
all macro usages from our own files.

* Remove wcelibcex folder

Poco now use C++17 and Windows CE does not support it and VS2017 does
also not support it so we can just remove Windows CE code. First remove
all macro usages from our own files.

* Remove rest Windows CE mentions

There where some Windows CE mentions left. Remove those.

* Update Windows CE documentation

We should keep documentation some time so people can find reason for
remove.

---------

Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
2023-12-14 00:25:04 +01:00
Matej Kenda
12a99dcd18 fix(SocketImpl): Windows: use pragma to link mswsock.lib 2023-12-12 22:13:00 +01:00
Alexander B
24b7122f43 add sendfile method for streamsocket (#4007)
* add sendfile method for streamsocket

* add mswsock.lib to the project files and templates

* remove /DPOCO_NO_AUTOMATIC_LIBS for cmake windows build

* merge from upstream

* merge from upstream

* fix code stile
add NotImplemented exception for unsupported platforms
exculude <sys/sendfile.h> for POCO_EMSCRIPTEN, because https://
github.com/emscripten-core/emscripten/pull/16234

* add iostream include for std::cout

* fix compilation for emscripten (wrap sendfile)
2023-12-11 10:47:03 +01:00
Matej Kenda
0e4eb00ea5 enh(Net): fix a typo 2023-12-04 16:56:12 +01:00
Russell Greene
3ae282db2e enh(Net): Allow passing raw fd's into ServerSocket (#4156)
* Allow creating ServerSocket's from fd's
* more sensible approach
* fix whitespace issue
* add test
* build fixes for windows
2023-12-04 16:53:40 +01:00