qicosmos / cinatra

modern c++(c++20), cross-platform, header-only, easy to use http framework
MIT License
1.81k stars 369 forks source link

feat: add websocket permessage-deflate #559

Closed helintongh closed 2 months ago

helintongh commented 2 months ago

websocket permessage-deflate also test by other language.

python websockets test code:

#!/usr/bin/env python

from websockets.sync.client import connect

def hello():
    with connect("ws://192.168.16.2:8090/ws") as websocket:
        s = 'string'.encode('ascii')
        websocket.send(s)
        message = websocket.recv()
        print(f"Received: {message}")

hello()

packets is as follows:

image

image

cinatra processing is complete.

github-actions[bot] commented 2 months ago

Code Coverage Report for detail, goto summary download Artifacts

Filename                              Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cinatra_log_wrapper.hpp                       4                 1    75.00%           9                 1    88.89%           0                 0         -
cookie.hpp                                   15                 2    86.67%          84                 2    97.62%          28                 3    89.29%
coro_http_client.hpp                         88                 6    93.18%        1426               218    84.71%         454               115    74.67%
coro_http_connection.hpp                     37                 2    94.59%         669               169    74.74%         196                63    67.86%
coro_http_request.hpp                        28                 4    85.71%         190                15    92.11%          72                 9    87.50%
coro_http_response.hpp                       27                 6    77.78%         206                64    68.93%          88                37    57.95%
coro_http_router.hpp                         15                 0   100.00%         181                32    82.32%          20                 8    60.00%
coro_http_server.hpp                         49                 3    93.88%         931                92    90.12%         182                47    74.18%
coro_radix_tree.hpp                          17                 1    94.12%         264                45    82.95%         136                33    75.74%
define.h                                      2                 0   100.00%          28                 2    92.86%          20                 1    95.00%
http_parser.hpp                              29                 5    82.76%         198                32    83.84%          54                12    77.78%
mime_types.hpp                                1                 0   100.00%           7                 2    71.43%           2                 1    50.00%
multipart.hpp                                 4                 0   100.00%          86                13    84.88%          20                 4    80.00%
picohttpparser.h                             14                 6    57.14%         467               278    40.47%         210               102    51.43%
response_cv.hpp                               2                 0   100.00%          55                32    41.82%          46                16    65.22%
session.hpp                                  11                 0   100.00%          54                 2    96.30%           4                 1    75.00%
session_manager.hpp                          10                 1    90.00%          67                 5    92.54%          10                 1    90.00%
sha1.hpp                                     12                 0   100.00%         181                 8    95.58%          12                 2    83.33%
string_resize.hpp                             2                 0   100.00%          18                 0   100.00%           2                 0   100.00%
time_util.hpp                                20                 7    65.00%         172                70    59.30%          28                 2    92.86%
uri.hpp                                      17                 5    70.59%         200                59    70.50%         166                49    70.48%
url_encode_decode.hpp                         4                 0   100.00%          85                20    76.47%          48                16    66.67%
utils.hpp                                    14                 0   100.00%         202                22    89.11%         116                43    62.93%
websocket.hpp                                14                 3    78.57%         172                13    92.44%          76                18    76.32%
ylt/coro_io/channel.hpp                      15                 0   100.00%         106                 7    93.40%          30                 5    83.33%
ylt/coro_io/client_pool.hpp                  21                 4    80.95%         326               141    56.75%          68                43    36.76%
ylt/coro_io/coro_file.hpp                    22                 1    95.45%         213                38    82.16%          56                19    66.07%
ylt/coro_io/coro_io.hpp                      51                 2    96.08%         325                15    95.38%           4                 1    75.00%
ylt/coro_io/detail/client_queue.hpp          10                 5    50.00%          47                23    51.06%          10                 4    60.00%
ylt/coro_io/io_context_pool.hpp              36                 5    86.11%         211                29    86.26%          28                 8    71.43%
ylt/util/concurrentqueue.h                   78                27    65.38%        1241               722    41.82%         290               198    31.72%
ylt/util/expected.hpp                         6                 4    33.33%           6                 4    33.33%           0                 0         -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                       675               100    85.19%        8427              2175    74.19%        2476               861    65.23%
github-actions[bot] commented 2 months ago

Code Coverage Report for detail, goto summary download Artifacts

Filename                              Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cinatra_log_wrapper.hpp                       4                 1    75.00%           9                 1    88.89%           0                 0         -
cookie.hpp                                   15                 2    86.67%          84                 2    97.62%          28                 3    89.29%
coro_http_client.hpp                         88                 6    93.18%        1426               218    84.71%         454               115    74.67%
coro_http_connection.hpp                     37                 2    94.59%         669               169    74.74%         196                64    67.35%
coro_http_request.hpp                        28                 4    85.71%         190                15    92.11%          72                 9    87.50%
coro_http_response.hpp                       27                 6    77.78%         206                64    68.93%          88                37    57.95%
coro_http_router.hpp                         15                 0   100.00%         181                32    82.32%          20                 8    60.00%
coro_http_server.hpp                         49                 3    93.88%         931                92    90.12%         182                47    74.18%
coro_radix_tree.hpp                          17                 1    94.12%         264                45    82.95%         136                33    75.74%
define.h                                      2                 0   100.00%          28                 2    92.86%          20                 1    95.00%
http_parser.hpp                              29                 5    82.76%         198                32    83.84%          54                12    77.78%
mime_types.hpp                                1                 0   100.00%           7                 2    71.43%           2                 1    50.00%
multipart.hpp                                 4                 0   100.00%          86                13    84.88%          20                 4    80.00%
picohttpparser.h                             14                 6    57.14%         467               278    40.47%         210               102    51.43%
response_cv.hpp                               2                 0   100.00%          55                32    41.82%          46                16    65.22%
session.hpp                                  11                 0   100.00%          54                 2    96.30%           4                 1    75.00%
session_manager.hpp                          10                 1    90.00%          67                 5    92.54%          10                 1    90.00%
sha1.hpp                                     12                 0   100.00%         181                 8    95.58%          12                 2    83.33%
string_resize.hpp                             2                 0   100.00%          18                 0   100.00%           2                 0   100.00%
time_util.hpp                                20                 7    65.00%         172                70    59.30%          28                 2    92.86%
uri.hpp                                      17                 5    70.59%         200                59    70.50%         166                49    70.48%
url_encode_decode.hpp                         4                 0   100.00%          85                20    76.47%          48                16    66.67%
utils.hpp                                    14                 0   100.00%         202                22    89.11%         116                43    62.93%
websocket.hpp                                14                 3    78.57%         172                13    92.44%          76                18    76.32%
ylt/coro_io/channel.hpp                      15                 0   100.00%         106                 7    93.40%          30                 5    83.33%
ylt/coro_io/client_pool.hpp                  21                 4    80.95%         326               141    56.75%          68                43    36.76%
ylt/coro_io/coro_file.hpp                    22                 1    95.45%         213                38    82.16%          56                19    66.07%
ylt/coro_io/coro_io.hpp                      51                 2    96.08%         325                15    95.38%           4                 1    75.00%
ylt/coro_io/detail/client_queue.hpp          10                 5    50.00%          47                23    51.06%          10                 4    60.00%
ylt/coro_io/io_context_pool.hpp              36                 5    86.11%         211                29    86.26%          28                 8    71.43%
ylt/util/concurrentqueue.h                   78                27    65.38%        1241               722    41.82%         290               198    31.72%
ylt/util/expected.hpp                         6                 4    33.33%           6                 4    33.33%           0                 0         -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                       675               100    85.19%        8427              2175    74.19%        2476               862    65.19%
github-actions[bot] commented 2 months ago

Code Coverage Report for detail, goto summary download Artifacts

Filename                              Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
cinatra_log_wrapper.hpp                       4                 1    75.00%           9                 1    88.89%           0                 0         -
cookie.hpp                                   15                 2    86.67%          84                 2    97.62%          28                 3    89.29%
coro_http_client.hpp                         88                 6    93.18%        1426               218    84.71%         454               115    74.67%
coro_http_connection.hpp                     37                 2    94.59%         669               169    74.74%         196                64    67.35%
coro_http_request.hpp                        28                 4    85.71%         190                15    92.11%          72                 9    87.50%
coro_http_response.hpp                       27                 6    77.78%         206                64    68.93%          88                37    57.95%
coro_http_router.hpp                         15                 0   100.00%         181                32    82.32%          20                 8    60.00%
coro_http_server.hpp                         49                 3    93.88%         931                92    90.12%         182                47    74.18%
coro_radix_tree.hpp                          17                 1    94.12%         264                45    82.95%         136                33    75.74%
define.h                                      2                 0   100.00%          28                 2    92.86%          20                 1    95.00%
http_parser.hpp                              29                 5    82.76%         198                32    83.84%          54                12    77.78%
mime_types.hpp                                1                 0   100.00%           7                 2    71.43%           2                 1    50.00%
multipart.hpp                                 4                 0   100.00%          86                13    84.88%          20                 4    80.00%
picohttpparser.h                             14                 6    57.14%         467               278    40.47%         210               102    51.43%
response_cv.hpp                               2                 0   100.00%          55                32    41.82%          46                16    65.22%
session.hpp                                  11                 0   100.00%          54                 2    96.30%           4                 1    75.00%
session_manager.hpp                          10                 1    90.00%          67                 5    92.54%          10                 1    90.00%
sha1.hpp                                     12                 0   100.00%         181                 8    95.58%          12                 2    83.33%
string_resize.hpp                             2                 0   100.00%          18                 0   100.00%           2                 0   100.00%
time_util.hpp                                20                 7    65.00%         172                70    59.30%          28                 2    92.86%
uri.hpp                                      17                 5    70.59%         200                59    70.50%         166                49    70.48%
url_encode_decode.hpp                         4                 0   100.00%          85                20    76.47%          48                16    66.67%
utils.hpp                                    14                 0   100.00%         202                22    89.11%         116                43    62.93%
websocket.hpp                                14                 3    78.57%         172                13    92.44%          76                18    76.32%
ylt/coro_io/channel.hpp                      15                 0   100.00%         106                 7    93.40%          30                 5    83.33%
ylt/coro_io/client_pool.hpp                  21                 4    80.95%         326               141    56.75%          68                43    36.76%
ylt/coro_io/coro_file.hpp                    22                 1    95.45%         213                38    82.16%          56                19    66.07%
ylt/coro_io/coro_io.hpp                      51                 2    96.08%         325                15    95.38%           4                 1    75.00%
ylt/coro_io/detail/client_queue.hpp          10                 5    50.00%          47                23    51.06%          10                 4    60.00%
ylt/coro_io/io_context_pool.hpp              36                 5    86.11%         211                29    86.26%          28                 8    71.43%
ylt/util/concurrentqueue.h                   78                27    65.38%        1241               722    41.82%         290               198    31.72%
ylt/util/expected.hpp                         6                 4    33.33%           6                 4    33.33%           0                 0         -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                       675               100    85.19%        8427              2175    74.19%        2476               862    65.19%