Commit Graph

738 Commits

Author SHA1 Message Date
mi01
b8cf739d27
Add cctype header (#656) 2020-09-16 16:32:49 -04:00
yhirose
7b55ecdc59 Fixed #650 2020-09-12 16:11:14 -04:00
tmahring
e9575bcb78
don't replace plus with space in headers (#649)
* don't replace plus with space in headers

* fixed forward handling with changed header parsing

* add test for boundaries containing plus chars
2020-09-10 20:27:01 -04:00
Jonas Minnberg
308aeb187b
Undefined if2ip() also on Android since getifaddrs() does not exist. (#648)
Co-authored-by: Jonas Minnberg <jonas@minnberg.se>
2020-09-10 07:52:01 -04:00
Ivan Fefer
3da4a0ac69
Add compression buffer size customization (#644)
* add compression buffer size customization and small brotli refactor

* allocat brotli buffer once

* add init to brotli decoder buffer
2020-09-08 12:18:14 -04:00
yhirose
9d12b3f20e Fixed warnings and refactoring 2020-09-03 20:33:30 -04:00
Omkar Jadhav
852a374748
Fix server crash caused due to regex complexity while matching headers. (#632)
* Fix parsing to parse query string with single space char.

When passed ' ' as a query string, the server crashes cause of illegal memory access done in httplib::detail::split. Have added checks to make sure the split function has a valid string with length > 0.

* Fix parsing to parse query string with single space char.

* Fix server crash caused due to regex complexity while matching headers.

While parsing content-type header in multipart form request the server crashes due to the exhaustion of max iterations performed while matching the input string with content-type regex.
Have removed the regex which might use backtracking while matching and replaced it with manual string processing. Have added tests as well.

* Remove magic number

Co-authored-by: Ivan Fefer <fefer.ivan@gmail.com>

Co-authored-by: yhirose <yhirose@users.noreply.github.com>
Co-authored-by: Ivan Fefer <fefer.ivan@gmail.com>
2020-09-03 13:17:52 -04:00
Ivan Fefer
3b5bab3308
Fix gzip_decompressor in case of one chunk being exactly equal to buffer size (#636)
* add larget chunks test

* revert test

* Fix gzip decoder in case of chunk being equal to buffer size

* add test
2020-09-03 12:20:02 -04:00
yhirose
69e75f4a67
Fix #635. HTTPS request stucked with proxy (#637) 2020-09-03 12:17:53 -04:00
Omkar Jadhav
b0fd4befb1
Fix query parsing issues (#629)
* Fix parsing to parse query string with single space char.

When passed ' ' as a query string, the server crashes cause of illegal memory access done in httplib::detail::split. Have added checks to make sure the split function has a valid string with length > 0.

* Fix parsing to parse query string with single space char.
2020-08-28 09:43:28 -04:00
yhirose
3e80666a74 Fix #628 2020-08-27 19:45:28 -04:00
yhirose
16df0ef37e Code cleanup 2020-08-26 12:18:49 -04:00
Ivan Fefer
f1a2ac5108
Avoid copying of content provider if possible (#627) 2020-08-26 08:56:51 -04:00
yhirose
e5903635e2 Fix #619 2020-08-22 12:54:43 -04:00
yhirose
510b4eaaae Fix #613 2020-08-17 13:40:06 -04:00
yhirose
e5dd410256 Added set_content_provider without content length 2020-08-15 05:53:49 -04:00
yhirose
951e46929e Fix #609 2020-08-14 15:01:09 -04:00
yhirose
c8adac30f4 Fix #564 again 2020-08-13 08:07:25 -04:00
R Edgar
649b1d2172
Fix nullptr_t issue (#605)
Clang complains that `nullptr_t` should be `std::nullptr_t
2020-08-09 16:45:53 -04:00
yhirose
dc5f9ba164
Better error handling on client (#601) 2020-08-08 20:50:24 -04:00
yhirose
04002d57bd Added set_default_headers (Fix #600) 2020-08-03 22:05:37 -04:00
yhirose
38a7706c8b Removed old Keep-Alive functions 2020-08-03 22:04:40 -04:00
PixlRainbow
5f76cb01c7
fix #592 -- add check for static-linked OpenSSL (#595) 2020-08-01 08:10:42 -04:00
yhirose
4f84eeb298 Bearer Token auth support. Fix #484 2020-07-31 12:37:14 -04:00
yhirose
a5b4cfadb9 Brotli suport on server. Fix #578 2020-07-31 10:23:57 -04:00
yhirose
3e906a9b8c Fix #591 2020-07-30 18:26:18 -04:00
yhirose
110393eadb Class name change 2020-07-30 17:27:07 -04:00
ThePiso
e130cf3a3b
The piso patch 1 (#590)
* Update httplib.h

When you disconnect and reconnect from the network, your network stack rewrites and updates /etc/resolv.conf accordingly. This configuration file is needed by the DNS resolver in the C library. The C library reads the DNS configuration from /etc/resolv.conf the first time, and caches it. It doesn't check, with every lookup, if the contents of /etc/resolv.conf have changed.
the solution is to add a call to res_init(), defined in resolv.h

* Update httplib.h
2020-07-30 10:11:02 -04:00
yhirose
8a348f17fd Resolved #192 2020-07-30 01:47:54 -04:00
yhirose
797d1f27e8 Fix #357 2020-07-29 23:12:05 -04:00
yhirose
6cce7951fc Fixed build error on non Windows environments with OpenSSL 2020-07-27 22:34:35 -04:00
yhirose
e9058e5639 Fixed build error on Windows with OpenSSL 2020-07-27 22:32:31 -04:00
yhirose
2538a85486 Fix #581 2020-07-27 22:07:04 -04:00
yhirose
12540fe8d3 Brotli support on client 2020-07-25 20:44:02 -04:00
yhirose
90da199aba Disable compression when content-type is text/event-stream 2020-07-25 10:46:52 -04:00
yhirose
9ca1fa8b18 Fix #576 2020-07-25 09:37:57 -04:00
yhirose
72ce293fed Removed set_timeout_sec and left set_base_dir 2020-07-20 17:15:16 -04:00
yhirose
b476b55771 Fix #557 2020-07-20 17:04:50 -04:00
yhirose
5ddaf949d0 Fixed build error on Windows 2020-07-19 18:32:28 -04:00
yhirose
457a5a7501 Added compressor class 2020-07-19 17:44:45 -04:00
Daniel Ottiger
2ce080c2cb
include <wincrypt.h> as otherwise CertOpenSystemStoreW can not be found (#568)
- visual studio 2019, version 16.6.3
- 64 bit target
2020-07-15 10:17:18 -04:00
yhirose
6ad25b6cf0 Fix #566 2020-07-12 20:41:02 -04:00
yhirose
3dff60eb16 Fix #565 2020-07-10 08:18:28 -04:00
yhirose
5038314b21 Fix #564 2020-07-08 13:56:06 -04:00
yhirose
6e1297cab0
Fix #150 (#556) 2020-07-07 18:55:46 -04:00
yhirose
7de743c962 Code format 2020-07-04 00:11:32 -04:00
Umiade
964fb5e5ca
Fix: regex can't match when proxy was set to some web debugger(e.g. Fiddler) (#553)
Co-authored-by: Umiade <hanyuchao@corp.netease.com>
2020-07-03 07:17:04 -04:00
yhirose
c4f3f9529b
Fix #534 (#546) 2020-07-02 21:57:50 -04:00
Ilya Tsybulsky
887def9490
Fix logger never called when write_content_with_provider returns false (#549) 2020-07-01 17:09:43 -04:00
Ilya Tsybulsky
bad6b2d22f
fix-the-code-won't compile-with-sdl-checks-on (#550) 2020-07-01 17:09:19 -04:00
rundong08
3d47a51430
Fixed comparison of integers of different signs. (#544) 2020-06-29 21:19:56 -04:00
yhirose
ce502a73e1 Fix #531 2020-06-22 14:56:18 -04:00
yhirose
6b22409217 Code format 2020-06-18 23:33:07 -04:00
yhirose
969cccd52a Use && for parameter of boundary 2020-06-18 23:32:09 -04:00
yhirose
4a9c048bbc Fixed problem with set_socket_options 2020-06-18 23:31:41 -04:00
yhirose
bfabbec8c7 Fix #528 2020-06-18 12:20:01 -04:00
yhirose
3e9c06cf79 Fixed #527 2020-06-18 12:18:43 -04:00
yhirose
29677540ae Removed unnecessary yeid. 2020-06-16 21:33:10 -04:00
yhirose
71fcfeb912 Removed unnecessary code 2020-06-16 21:21:03 -04:00
yhirose
c7d22e451f Fixed timeout calculation bugs 2020-06-16 21:20:47 -04:00
yhirose
42f9f9107f Updated version in the User Agent string 2020-06-16 17:53:15 -04:00
yhirose
7cd25fbd63 Fix #499 2020-06-16 17:46:23 -04:00
yhirose
3dfb4ecac2 Fix #522 2020-06-15 23:09:46 -04:00
yhirose
144114f316 Fixed warnings on Windows 2020-06-13 23:20:21 -04:00
yhirose
0743d78c9b Fixed ClientStop test error. 2020-06-14 03:01:41 +00:00
yhirose
e022b8b80b Refactoring to make it ready for KeepAlive connection on Client 2020-06-13 21:42:23 -04:00
yhirose
f80b6bd980 Added Endpoint structure in Client 2020-06-13 01:26:57 -04:00
yhirose
5af7222217 Fixed Client::stop problem with more than one requests on threads 2020-06-12 11:04:37 -04:00
yhirose
24bdb736f0 Fix #506 2020-06-09 19:58:01 -04:00
yhirose
d0dc200633 Code format 2020-06-09 19:17:58 -04:00
Nicolas Schneider
919a51091f
replace usage of [[deprecated]] with CPPHTTPLIB_DEPRECATED (#513) 2020-06-03 13:12:31 -04:00
Nicolas Schneider
05e8b22989
fix cast warning (#512) 2020-06-03 07:44:16 -04:00
Nicolas Schneider
00dcd6b004
check for [[deprecated]] support via feature test macro (#511)
The [[deprecated]] specifier is a C++14 feature, so it might not always
be available on a C++11 compiler.
2020-06-03 07:43:56 -04:00
yhirose
a42c6b99d3 Code cleanup 2020-06-02 19:06:16 -04:00
Wang Gao
812cb5bc3d
fix get value function (#509) 2020-06-02 19:05:04 -04:00
yhirose
aea60feb85 Code cleanup 2020-06-01 13:22:02 -04:00
yhirose
b3a4045300 Fix #503 2020-05-28 19:19:18 -04:00
yhirose
d9fe3fa020 Fix #504 2020-05-28 17:08:05 -04:00
yhirose
d8612ac02d Fixed build error... 2020-05-28 12:51:52 -04:00
yhirose
83ee6007da Fix #500 2020-05-28 12:06:11 -04:00
yhirose
3eaa769a2d Fix #481, #483, #487 2020-05-26 18:34:32 -04:00
yhirose
b91540514d Fix #494 2020-05-25 10:50:24 -04:00
yhirose
ab563ff52c Fix #496 2020-05-25 10:38:47 -04:00
yhirose
be7962f140 Fix #489 2020-05-24 15:18:34 -04:00
yhirose
630f3465a9 Deprecated set_timeout_sec, added set_connection_timeout. 2020-05-23 18:00:24 -04:00
yhirose
9af1a4a08f Fixed problem with stop on windows 2020-05-23 13:49:49 -04:00
yhirose
0654e5dab4 Changed CPPHTTPLIB_IDLE_INTERVAL_USECOND to 0 2020-05-23 08:44:03 -04:00
yhirose
62e036f253 Fixed #488 again 2020-05-22 18:24:01 -04:00
yhirose
f0adfb2e0c Fix #488 2020-05-22 12:18:07 -04:00
yhirose
139c816c16 Fixed the location of Client2 2020-05-19 21:02:58 -04:00
yhirose
29fd136afd Code cleanup and format 2020-05-16 17:35:04 -04:00
yhirose
f5598237b2 Fixed many redirects problem on Proxy 2020-05-16 17:34:03 -04:00
Daniel Ottiger
01058659ab
make write timeout configurable (like the read timeout already is) (#477)
In case we want to send a lot of data,
and the receiver is slower than the sender.

This will first fill up the receivers queues and after this
eventually also the senders queues,
until the socket is temporarily unable to accept more data to send.

select_write is done with an timeout of zero,
which makes the select call used always return immediately:
(see http://man7.org/linux/man-pages/man2/select.2.html)

This means that every marginal unavailability will make it return false
for is_writable and therefore httplib will immediately abort the transfer.

Therefore make this values configurable in the same way
as the read timeout already is.

Set the default write timeout to 5 seconds,
the same default value used for the read timeout.
2020-05-16 17:31:46 -04:00
yhirose
b9a9df4d73 Fixed problem with writing large data 2020-05-15 22:21:58 -04:00
yhirose
25aa3ca982 Added std::ostream os in DataSink. 2020-05-15 21:26:13 -04:00
yhirose
f4c5d94d74 Updated version in the User Agent string 2020-05-14 18:07:02 -04:00
yhirose
63a96aeb20 Improved Client2 interface 2020-05-14 12:51:34 -04:00
yhirose
bbb83d12c1 Removed default parameter values in Client and SSLClient constructors 2020-05-14 08:51:32 -04:00
yhirose
2d4b42b70b Removed url 2020-05-14 01:43:06 -04:00
yhirose
1919d08f71 Added Client2 2020-05-14 01:36:56 -04:00
yhirose
824c02fcd3 Code cleanup 2020-05-14 01:08:36 -04:00
yhirose
2c0613f211 Fix #472 2020-05-13 21:48:14 -04:00
Saika Fatih
803ebe1e20
Typos fixed (#474) 2020-05-12 13:18:58 -04:00
yhirose
ba685dbe48 Fixed potential infinite loop with content receiver 2020-05-10 20:45:57 -04:00
yhirose
49c4c2f9c1 Fix #459 2020-05-10 20:39:16 -04:00
yhirose
58909f5917 Fix #466 2020-05-10 15:58:53 -04:00
yhirose
5982b5c360 Fix #471 2020-05-10 14:18:03 -04:00
PixlRainbow
5bb4c12c6b
Fix #465 (#467)
update digest header username to use username parameter instead of "hello" test value
2020-05-09 08:29:08 -04:00
Daniel Ottiger
d043b18097
keepalive: support multiple post using content provider (#461) 2020-05-07 08:31:14 -04:00
yhirose
8728db7477 Apply IPV6_V6ONLY only when socket is AF_INET6 2020-05-04 22:16:43 -04:00
Daniel Ottiger
b2203bb05a
server: support dual-stack server socket (#450)
According to RFC 3493 the socket option IPV6_V6ONLY
should be off by default, see
https://tools.ietf.org/html/rfc3493#page-22 (chapter 5.3).

However this does not seem to be the case on all systems.
For instance on any Windows OS, the option is on by default.

Therefore clear this option in order to allow
an server socket which can support IPv6 and IPv4 at the same time.
2020-05-04 22:13:12 -04:00
yhirose
d45250fd88 Appled HANDLE_EINTR to send and select system calls 2020-05-01 21:38:23 -04:00
yhirose
528cacdc0d Changed CPPHTTPLIB_THREAD_POOL_COUNT back to 8. (#454) 2020-05-01 21:23:02 -04:00
Matthew DeVore
ed1b6afa10
Fix crash caused by header field regex complexity (#457) 2020-05-01 12:44:13 -04:00
yhirose
08fc7085e5 Fixed #456 2020-04-30 19:40:23 -04:00
yhirose
8333340e2c Chagned to use inline function instead of macro 2020-04-27 12:36:39 -04:00
Jan Lukavsky
b0a189e50e Sketch handling EINTR errors 2020-04-27 17:36:44 +02:00
yhirose
776b3ffbf9 Code format 2020-04-25 18:01:48 -04:00
yhirose
d359e3a5f7 Renave queue_adjust to on_idle (#442) 2020-04-25 17:56:55 -04:00
evg82
5928e0af1a
TaskQueue method to internal size adjust (#442)
I use a custom TaskQueue, with variable number of workers, adding workers on demand is an easy task when new connection arrive (in enqueue function) however i need another funtion to be called even (or better) went no new connections arrives to reduce workers count. I only added a new virtual method in TaskQueue class to allow custom class to adjust workers size over time. Even if this methods is called frequenlty custom class can keep a "last_update" counter to check if need to adjust worker count or any other internal task. Without this function i need an external thread to make this adjust task.
2020-04-25 17:55:20 -04:00
yhirose
a5005789ff
Fixed Visual Studio compiler warnings with x64 platform (Resolve #440 and #446) (#448) 2020-04-25 17:13:14 -04:00
Hoa Thiên Vũ
2feea0c9ab
Fixed error: ‘ULONG_MAX’ was not declared in this scope on line 1921 (#445)
* Fixed error:
ULONG_MAX is defined in the limits.h header file. Putting #include <climits>
```
httplib.h: In function ‘bool httplib::detail::read_content_chunked(httplib::Stream&, httplib::ContentReceiver)’:
httplib.h:1921:22: error: ‘ULONG_MAX’ was not declared in this scope
     if (chunk_len == ULONG_MAX) { return false; }
                      ^~~~~~~~~
httplib.h:1921:22: note: suggested alternative: ‘_SC_ULONG_MAX’
     if (chunk_len == ULONG_MAX) { return false; }
                      ^~~~~~~~~
                      _SC_ULONG_MAX
```

* Move #include <climits> to after #include <cassert>
2020-04-24 12:02:19 -04:00
yhirose
a2e4af54b7 Fix #399 2020-04-23 23:09:04 -04:00
yhirose
d0b123be26 Support remote_addr and remote_port REMOTE_PORT header in client Request (#433) 2020-04-23 22:12:12 -04:00
Matthew DeVore
df138366e4
Fail to read a chunk if its length is >= ULONG_MAX (#444)
We cannot trivially support such large chunks, and the maximum value
std::strtoul can parse accurately is ULONG_MAX-1. Error out early if the
length is longer than that.
2020-04-23 10:59:15 -04:00
Matthew DeVore
c49441ae64
Do not throw exceptions when parsing request chunks (#441)
detail::read_content_chunked was using std::stoul to parse the
hexadecimal chunk lengths for "Transfer-Encoding: chunked" requests.
This throws an exception if the string does not begin with any valid
digits. read_content_chunked is not called in the context of a try block
so this caused the process to terminate.

Rather than use exceptions, I opted for std::stroul, which is similar to
std::stoul but does not throw exceptions. Since malformed user input is
not particularly exceptional, and some projects are compiled without
exception support, this approach seems both more portable and more
correct.
2020-04-23 09:05:45 -04:00
yhirose
ad9fd3bd93 Fix #436 2020-04-22 21:42:58 -04:00
yhirose
da26b517a3 Added url::Get interface 2020-04-21 23:00:39 -04:00
yhirose
240cc85ccb Fixed regex problem for recirect location 2020-04-21 21:18:29 -04:00
yhirose
129e2f00b8 Removed unnecessary noexcept 2020-04-20 19:42:05 -04:00
Daniel Ottiger
da746c6e67
SSLClient::set_ca_cert_store: mark as inline (#435) 2020-04-20 12:53:39 -04:00
yhirose
3451da940d Code format 2020-04-19 22:05:04 -04:00
yhirose
38a6b3e69f Fixed warning 2020-04-19 22:04:29 -04:00
Daniel Ottiger
2ece5f116b
Pass certs and keys from memory (#432)
* SSLServer: add constructor to pass ssl-certificates and key from memory

* SSLClient: add constructor to pass ssl-certificates and key from memory

* add TestCase for passing certificates from memory to SSLClient/SSLServer
2020-04-18 16:26:06 -04:00
yhirose
c2b6e4ac04 Fix #431 2020-04-17 21:48:16 -04:00
yhirose
85327e19ae Fix #425 2020-04-12 15:33:08 -04:00
Alexandre Taillefer
ed8efea98b
Added support for DELETE request body (#418)
* Added support for DELETE request body

* Fixed DELETE request body test case typo

Co-authored-by: Alexandre Taillefer <alexandre.taillefer@pwc.ca>
2020-04-07 15:51:52 -04:00
Max
1ccddd1b0b
SSL_shutdown() only if not already closed by remote (#413) 2020-04-06 10:30:21 -04:00
yhirose
992f3dc690 Code cleanup 2020-04-03 09:33:29 -04:00
yhirose
402d47e2cd Fix #407 2020-03-31 19:42:53 -04:00
yhirose
171fc2e353 Fix #403. Added more status codes based on MDN document 2020-03-26 20:50:40 -04:00
SoenkeHeeren
ced4160d05
add http status code 201 to show the right status message in return headers (#402) 2020-03-26 12:20:32 -04:00
Igor [hyperxor]
dc13cde820
Minor improvements in httplib classes (#395) 2020-03-23 06:54:13 -04:00
Andrew Gasparovic
914c8860e8 Accept content by value to allow moving
Previously, calling set_content always resulted in 's' being copied. With this change, there will still be the same number of copies made (1) when doing `set_content(my_value, ...)`, but there will be no copies if a caller elects to do `set_content(std::move(value), ...)` or `set_content(some_function_that_returns_a_temporary(), ...)` instead.
2020-03-21 00:39:07 -04:00
yhirose
685533ba50 Fixed warnings on Windows due to max/min macro 2020-03-16 13:58:09 -04:00
yhirose
e1acb949e7 Fix #382 2020-03-13 18:43:29 -04:00
Oleg Vorobiov
7b3cea5317
Prevent an implicit capture of 'this' via '[=]' (#381) 2020-03-12 12:31:22 -04:00
yhirose
26deffe0c6 Not to send 'EXCEPTION_WHAT' header to client 2020-03-10 17:44:36 -04:00
Rafael Leira
e07c5fec01 simplest way to catch handler exceptions 2020-03-10 17:44:36 -04:00
miketsts
6e473a7c5c
Fix conversion to ‘int’ from ‘long int’ warning (#377)
Co-authored-by: Michael Tseitlin <michael.tseitlin@concertio.com>
2020-03-10 14:48:14 -04:00
yhirose
c74129a1c2
Fix #372 (#374) 2020-03-09 23:59:00 -04:00
yhirose
18e750b4e7 Code cleanup 2020-03-09 19:47:28 -04:00
Matthew DeVore
bf7700d192
Fix exception that occurs with libc++ regex engine (#368)
The regex that parses header lines potentially causes an unlimited
amount of backtracking, which can cause an exception in the libc++ regex
engine.

The exception that occurs looks like this and is identical to the
message of the exception fixed in
https://github.com/yhirose/cpp-httplib/pull/280:

	libc++abi.dylib: terminating with uncaught exception of type
	std::__1::regex_error: The complexity of an attempted match
	against a regular expression exceeded a pre-set level.

This commit eliminates the problematic backtracking.
2020-02-28 06:31:39 -05:00
yhirose
4c3b119dde Code format 2020-02-24 21:17:02 -05:00
hyperxor
ccc9a9b3f4 Remove code duplication in converting params to query 2020-02-25 02:30:34 +03:00
rymis
f2bb9c45d6
Support for deflate compression (#360) 2020-02-24 11:48:00 -05:00
yhirose
d0d744d520 Fixed compiler warning with Visual C++. Close #358 2020-02-20 17:30:04 -05:00
yhirose
fce8e6fefd
Merge pull request #356 from samhocevar/fix-shadow-declarations
Fix a few shadowed variable compilation warnings.
2020-02-17 09:01:47 -05:00
Sam Hocevar
180aa32ebf Fix a few shadowed variable compilation warnings. 2020-02-17 06:58:30 +01:00
yhirose
064cc6810e Fix #352 2020-02-13 17:40:06 -05:00
yhirose
464cc89b77 Fix #351 2020-02-12 22:35:52 -05:00
yhirose
ca5a50d2c9 Fix #349 2020-02-11 00:26:15 -05:00
yhirose
851edaf77f Code format 2020-02-02 20:02:16 -05:00
yhirose
ac7742bb32 Changed the order of parameters of set_mounting_point. 2020-02-01 09:18:24 -05:00
yhirose
8801e51138 Fix #341 2020-01-31 20:35:20 -05:00
Vitaly Takmazov
5e43680486 HEAD support for static file server 2020-01-28 12:00:27 +03:00
yhirose
79df842cc5 Updated README 2020-01-26 18:34:50 -05:00
yhirose
2e360f9dd6 Improved Stream interface 2020-01-16 23:28:11 -05:00
Valentin Vanelslande
126f1d177e
Add status message: 503 Service Unavailable 2020-01-16 00:59:24 -05:00
yhirose
b557ac9328 Code format 2020-01-14 17:04:51 -05:00
yhirose
f6db19959f
Merge pull request #333 from stupedama/master
std:🧵:hardware_concurrency
2020-01-14 17:04:17 -05:00
yhirose
6b4df41b30 Fix #330 2020-01-14 17:02:25 -05:00
yhirose
0d81e20129 Fix #332 2020-01-14 14:59:20 -05:00
Fredrik Fjeldvær
26cb83ed6c if std:🧵:hardware_concurrency() is 0 use 2 threads. also -1 thread because we already have one thread from the main function 2020-01-14 17:48:51 +01:00
Valentin Vanelslande
db27812198
Add status message for 202 Accepted 2020-01-10 17:50:37 -05:00
yhirose
6fe6fd5dbe Fixed build errors 2020-01-10 09:40:26 -05:00
yhirose
0ee9660f3d Code format 2020-01-10 09:35:07 -05:00
yhirose
a15d16a9de Moved Stream concrete classes into detail namespace 2020-01-10 09:33:14 -05:00
Tyler Rockwood
fcdaa24fc5
Properly implement BufferStream::read
The existing implementation did not advance the buffer at all.
2020-01-09 22:05:59 -06:00
hyperxor
b16905ec8b Fix Response move 2020-01-08 23:13:04 +03:00
yhirose
2f72845008 Fix #319 2020-01-07 23:40:11 -05:00
hyperxor
568fda62b4 Tiny improvement in DataSink class 2020-01-07 13:25:04 +03:00
yhirose
96e9ec0663 Improved DataSink interface 2020-01-05 23:59:54 -05:00
yhirose
d2fae4031c Fixed build errors 2020-01-03 01:36:59 -05:00
yhirose
de844e67ef Proxy support for Keep-Alive requests 2020-01-03 01:24:07 -05:00
yhirose
6c0e021554 Fixed socket leak 2020-01-02 17:01:02 -05:00
yhirose
aa630e3062 Fix #311 2020-01-02 13:02:05 -05:00
yhirose
fcbcbd53bd Fix #306 2019-12-26 18:48:22 -05:00
yhirose
1bf616d653 Fix #303 2019-12-26 17:50:53 -05:00
yhirose
2c6da365d9
Merge pull request #300 from vvanelslande/accpet
Change Accpet-Encoding to Accept-Encoding
2019-12-22 15:39:47 -05:00
yhirose
38adeaf02c Fixed problem with proxy support and added unit tests 2019-12-22 15:37:01 -05:00
Valentin Vanelslande
b3814b2b80
Change Accpet-Encoding to Accept-Encoding 2019-12-22 13:02:20 -05:00
yhirose
a444b612af V0.5.0 2019-12-22 12:52:08 -05:00
yhirose
ed6d949f42 Fix #299 2019-12-22 12:50:25 -05:00
yhirose
d28cd3f937 Code cleanup 2019-12-21 23:20:30 -05:00
yhirose
8cc3e6c434
Merge pull request #296 from yhirose/connect
CONNECT method support on client
2019-12-21 23:09:10 -05:00
hyperxor
0dc653f45a Fix redundant Progress copy in Get methods 2019-12-21 10:57:06 +03:00
yhirose
a1cfc0f377 Fixed problem with redirect 2019-12-20 13:25:11 -05:00
yhirose
eb4fcb5003 CONNECT method support on client 2019-12-20 06:59:59 -05:00
yhirose
ae43c96984
Merge pull request #295 from yhirose/timeout
Fix #294
2019-12-18 17:57:23 -05:00
yhirose
9c81693801 Fix #294 2019-12-18 17:47:36 -05:00
yhirose
80202c9f62
Merge pull request #292 from Bendr0id/fix_socket_create_on_older_windows_systems
Adds workaround for socket creation on older Windows variants
2019-12-18 07:09:48 -05:00
Ben Gräf
094a6a614a Adds workaround for socket creation on older Windows variants
Since the WSA_FLAG_NO_HANDLE_INHERIT is only supported on Windows 7 SP1 and above the socket creation fails on older Windows Systems.
     
Let's try to create a socket the old way in this case.
     
Reference:
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketa
     
WSA_FLAG_NO_HANDLE_INHERIT:
This flag is supported on Windows 7 with SP1, Windows Server 2008 R2 with SP1, and later
2019-12-18 07:49:36 +01:00
yhirose
39c7bba7b9 Code cleanup 2019-12-17 13:05:08 -05:00
yhirose
f2476f21fc Fixed URL encoding problem when sending a request to proxy 2019-12-17 12:58:25 -05:00
yhirose
9a41b16cbb Fix #285. Added set_interface method on client 2019-12-15 17:44:00 -05:00
yhirose
260422b7d7 Format code 2019-12-14 23:46:11 -05:00
yhirose
d2c7b447d5 Fix #289: Fixed build problem with Visual C++ 2019-12-13 09:12:50 -05:00
yhirose
72b20c08da Better API names 2019-12-13 06:56:00 -05:00
yhirose
afd6d5f9dc Removed compress parameter and added compress method on client 2019-12-12 23:09:59 -05:00
yhirose
5324b3d661 Improved multipart form data interface 2019-12-12 22:48:09 -05:00
yhirose
151ccba57e Code cleanup 2019-12-12 21:50:12 -05:00
yhirose
69a28d50f6 Fix #287 2019-12-12 12:50:45 -05:00
Yuji Hirose
3c2736bb2a Fixed regex syntax error 2019-12-10 13:07:49 -05:00
Yuji Hirose
fd4e1b4112 Fix #266 2019-12-10 12:10:14 -05:00
yhirose
f6a2365ca5 Fix #282 2019-12-06 12:21:15 -05:00
yhirose
df1ff7510b Made code more readable 2019-12-06 12:02:08 -05:00
yhirose
379905bd34 Merge branch 'whitespace-and-libcxx-compat' of https://github.com/matvore/cpp-httplib 2019-12-06 09:51:21 -05:00
Matthew DeVore
bc9251ea49 Work around incompatibility in <regex> in libc++
libc++ (the implementation of the C++ standard library usually used by
Clang) throws an exception for the regex used by parse_headers before
this patch for certain strings. Work around this by simplifying the
regex and parsing the header lines "by hand" partially. I have repro'd
this problem with Xcode 11.1 which I believe uses libc++ version 8.

This may be a bug in libc++ as I can't see why the regex would result in
asymptotic run-time complexity for any strings. However, it may take a
while for libc++ to be fixed and for everyone to migrate to it, so it
makes sense to work around it in this codebase for now.
2019-12-05 17:14:16 -08:00
Matthew DeVore
a9e942d755 Properly trim whitespace from headers
HTTP Whitespace and regex whitespace are not the same, so we can't use
\s in regexes when parsing HTTP headers. Instead, explicitly specify
what is considered whitespace in the regex.
2019-12-05 17:14:16 -08:00
Barry McNamara
e1785d6723 Remove use of exceptions. 2019-12-05 15:56:55 -08:00
yhirose
033bc35723 Improve multipart content reader interface 2019-12-02 07:11:12 -05:00
yhirose
b69c0a1dcb Content receiver support for multipart content (Fix #241) 2019-12-01 22:04:26 -05:00
yhirose
295e4d58aa Fix #276 2019-11-29 17:07:51 -05:00
yhirose
6f58dc728f Fixed problem with requests with no content 2019-11-28 08:28:01 -05:00
yhirose
880f7fa62b Fix #273 2019-11-27 12:54:01 -05:00
yhirose
8f3dbf7f21 Code cleanup 2019-11-27 08:01:25 -05:00
yhirose
924a557fa3 Changed to use 'using' instead of 'typedef' 2019-11-27 07:03:17 -05:00
yhirose
d8da740597 Fix #270 2019-11-26 08:48:17 -05:00
yhirose
d45676b064 Added NoThread task queue 2019-11-25 13:00:37 -05:00
Hirose Family
94d13e88a5 Fixed regex problem with Apple LLVM version 8.0.0 2019-11-03 19:27:12 -05:00
Johan Jansen
a62a48a7b5 Modernize some additional code 2019-10-31 21:49:04 +01:00
Johan Jansen
c652919954 Do not use shared_ptr where not required 2019-10-31 21:48:48 +01:00
Johan Jansen
58753ba33c Fix some virtual override warnings 2019-10-31 21:38:37 +01:00
yhirose
5706828d2c Replace C-style arrays and fix static-code analysis warnings 2019-10-31 21:32:07 +01:00
yhirose
e743b8cd57 Fix #254 2019-10-30 08:21:59 -04:00
yhirose
9d57899352 Simplified ContentReceiver interface 2019-10-27 23:38:56 -04:00
yhirose
d03937e144 Content receiver support on server 2019-10-27 23:20:56 -04:00
yhirose
8fb37a449d Fix #251 2019-10-27 17:27:57 -04:00
yhirose
f0b1b5dbfd Added set_read_timeout. Fix #248. 2019-10-27 14:57:22 -04:00
yhirose
5f32c424c2 Content provider support on client 2019-10-25 18:39:04 -04:00
yhirose
f0683f2301 Fixed build errors 2019-10-25 13:11:49 -04:00
yhirose
0d527e2b83 Code formatting 2019-10-25 12:09:26 -04:00
yhirose
bea3ebd7af Added 'compress' option to POST, PUT and PATCH. 2019-10-25 11:46:12 -04:00
yhirose
380f725713 Code format 2019-10-24 22:20:42 -04:00
Bastien Durel
d1abf96581
html files may be .htm 2019-10-23 09:52:21 +02:00
yhirose
7a3abd2768
Merge pull request #243 from Sil3ntStorm/patch1
Allow use of OpenSSL 1.1.1, fix compile errors
2019-10-20 10:12:14 -04:00
Aaron Albers
89e1e9b8fe Added bind_to_port()
- This compliments the existing `bind_to_any_port()`
  where you can determine if the bind succeeded prior
  to calling `listen_after_bind()` but allows you to
  specify the port.
2019-10-19 10:41:19 -06:00
Sil3ntStorm
98d16eb836 Allow use of OpenSSL 1.1.1, fix compile errors 2019-10-19 16:40:06 +02:00
yhirose
dcdb0d047b Fixed PRI request problem 2019-10-03 13:44:18 -04:00
yhirose
1f86e41d97 Changed back to select as default 2019-10-03 13:44:18 -04:00
Johan Jansen
f23f9a06a9 Allow configuration to be overriden without source editing 2019-09-30 22:00:17 +02:00
Alin Gherman
224119a60a Retry in case of too many sockets opened instead of stopping the server. 2019-09-30 11:48:02 +02:00
yhirose
c02849e269 Removed CPPHTTPLIB_USE_POLL, added CPPHTTPLIB_USE_SELECT 2019-09-29 19:43:22 -04:00
yhirose
71979b1e88
Merge pull request #226 from Zefz/mingw-compile-fix
Fix compilation on Mingw-64
2019-09-27 17:29:33 -04:00
zefz
b14b7b0f8f Fix compilation on Mingw-64 2019-09-27 20:23:16 +02:00
Tang Huaizhe
9dbe0d855c Fix compile error in android ndk 2019-09-27 13:32:23 +08:00
Johan Jansen
94fc229c44 Add missing explicit const_cast 2019-09-26 22:20:33 +02:00
Johan Jansen
a7052cba22 Fix several -Wold-style-cast warnings in Clang-9 2019-09-26 22:03:18 +02:00
yhirose
c946eb7699 Fixed warnings on Windows 2019-09-26 08:13:20 -04:00
PolloLoco
c7f8561472 Added ssl_context member function to SSLClient in
order to allow access to the SSL_CTX struct, for
example to load the windows cert store
2019-09-18 15:10:15 +02:00
yhirose
4ab9270660 Use 'poll' as default instead of select (Fix #215) 2019-09-18 08:42:18 -04:00
yhirose
d599a36c2a Format code 2019-09-16 17:48:17 -04:00
yhirose
0c293887d0 Fixed problem with redirect 2019-09-15 09:15:21 -04:00
Steffen Schuemann
7e92ffec48 Added new Client::Get variant that combines a ContentReceiver with a new ResponseHandler
While trying to implement streaming of internet radio, where a ContentReceiver is needed to handle the audio data, I had the problem, that important information about the stream data is part of the HTTP header (e.g. size of audio chunks between meta data), so I added a ResponseHandler and a new Get variant, to gain access to the header before handling the first chunk of data.

The ResponseHandler can abort the request by returning false, in the same way as the ContentReceiver.

A test case was also added.
2019-09-14 14:55:12 +02:00
yhirose
c9238434e1 Added redirect support (Fix #211) 2019-09-06 18:07:35 -04:00
yhirose
e2babf315c Fixed build error on Windows 2019-09-05 13:22:44 -04:00
yhirose
c434d555bb Fixed problem caused by former changes 2019-09-03 17:19:58 -04:00
yhirose
80f040cf69 Fix #209 2019-09-03 17:10:04 -04:00
yhirose
037b4fc789 Fixed problem with keep-alive on client 2019-09-03 17:05:10 -04:00
yhirose
a782d1b609 Added OpenSSL version check. (Currently commented out) 2019-08-31 20:15:50 -04:00
yhirose
1e82359329 Keep-alive connection support on client (Fix #36) 2019-08-31 17:52:24 -04:00
yhirose
a4160e6ac1 Fix #212 2019-08-25 17:19:20 -04:00
yhirose
bdbfc6cfe7 Fix #210 2019-08-25 16:49:10 -04:00
yhirose
22615f9682 Fix #203 2019-08-07 06:34:24 -04:00
yhirose
64991a560a Fixed problems with Win32 build 2019-08-07 15:21:22 +09:00
yhirose
d7bb402ca7 Format code 2019-08-06 18:12:05 +09:00
yhirose
d58deddbcc Fixed #198 2019-08-06 18:10:41 +09:00
yhirose
3629f87627 Fixed thread pool problem. 2019-08-06 08:31:43 +09:00
yhirose
2823a94fc1 Added 'resource_releaser' for content provider 2019-08-05 09:40:23 +09:00
yhirose
f4aaba6362 Fixed warnings on Windows 2019-08-03 20:43:15 -04:00
yhirose
c899462e75 Added 'Content-Range' header for single range request 2019-08-03 22:12:24 +09:00
yhirose
9785cd47f2 Thread pool support 2019-08-03 16:39:39 +09:00
yhirose
579ff1a0a6 new_task_queue support 2019-08-03 13:15:05 +09:00
yhirose
47312e6df9 Added TaskQueue interface 2019-08-03 12:11:22 +09:00
yhirose
66b81a1497 Code cleanup 2019-08-03 10:47:48 +09:00
yhirose
9d7b717504 Range header support and redesign of content provider interface 2019-08-03 03:28:39 +09:00
yhirose
58f72bc8b6 Code cleanup 2019-07-29 14:24:40 -04:00
yhirose
4c58b91e40 Added additonal status messages 2019-07-29 09:47:50 -04:00
yhirose
06b3dee5aa Code cleanup 2019-07-28 19:12:44 -04:00
yhirose
d15df874b3 Code cleanup 2019-07-28 07:52:57 -04:00
yhirose
f40de531ab Fix #196 2019-07-26 14:39:09 -04:00
yhirose
cb11d9412e Fixed connection end problem with HTTP/1.0 client 2019-07-24 06:53:48 -04:00
yhirose
34651ef89b Fix #121 2019-07-23 09:53:44 -04:00
yhirose
dd20e4d418 Fixed build errors 2019-07-22 06:58:05 -04:00
yhirose
7267b3f3e2 Write error handling 2019-07-21 21:34:49 -04:00
yhirose
4c18ac2b18 Added locking_callback for OpenSSL versions prior to 1.1.0 2019-07-19 17:03:47 -04:00
yhirose
eaafa5d55c Fix #127 2019-07-19 11:38:06 -04:00
yhirose
3d1ae3a3af Code cleanup 2019-07-17 23:50:47 -04:00
yhirose
6f663028e9 Fix #139. Content receiver support 2019-07-17 22:00:18 -04:00