1. 01 Nov, 2019 2 commits
  2. 29 Oct, 2019 4 commits
  3. 28 Oct, 2019 4 commits
  4. 18 Oct, 2019 6 commits
  5. 17 Oct, 2019 1 commit
    • Louis Solofrizzo's avatar
      Transport: Fix static file serving from SSL connections · 44e40478
      Louis Solofrizzo authored
      This patch fixes the behavior of serveFile with SSL enabled servers.
      Before, the sendfile(2) syscall was used, but cannot work if our current
      version of OpenSSL, because the transfer happens kernel-side, and the
      SSL encryption does not. So I've implemented a _very_ basic sendfile
      utility for SSL connections, which only stream 4096 bytes of the file
      per call, in order not to block the whole pipeline.
      
      It's worth noting that this patch will be useless when the upstream
      moves to OpenSSL 3.0, which uses Kernel TLS, and implement a zero-copy
      version of SSL_sendfile, which is far more superior than the one
      implemented in this patch.
      
      I've tested the basic use cases with this patch, whis is file
      downloading. I've used small and big (45G) files, and it appears to be
      working.
      
      I've launched kip's tests[1] on my code, and it seems to be passing
      everything:
      
                Start 25: https_server_test
          25/25 Test #25: https_server_test ................   Passed    0.07 sec
      
      [1] https://github.com/kiplingw/pistache/tree/kip-ssl-servefile-test
      
      Here is my example file:
      
          #include <pistache/endpoint.h>
          #include <iostream>
      
          using namespace Pistache;
      
          struct HelloHandler : public Http::Handler {
              HTTP_PROTOTYPE(HelloHandler)
      
              void onRequest(const Http::Request& request, Http::ResponseWriter writer) {
                  Http::serveFile(writer, "main.cpp");
              }
          };
      
          int main(void) {
              std::cout << "Starting server\n";
              Pistache::Address addr;
              auto opts = Http::Endpoint::options().threads(5);
      
              addr = Pistache::Address(Pistache::Ipv4::any(), Pistache::Port(9999));
      
              Http::Endpoint server(addr);
              server.init(opts);
              server.setHandler(std::make_shared<HelloHandler>());
              server.useSSL("./cas/server/server.crt", "./cas/server/server.key", true);
              std::cout << "SSL enabled\n";
      
              server.serve();
              return 0;
          }
      
          $> curl https://localhost:9999 -k > test
            % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                           Dload  Upload   Total   Spent    Left  Speed
          100   770  100   770    0     0  30800      0 --:--:-- --:--:-- --:--:-- 30800
          $> diff test main.cpp
          $>
      
      Pull Request: https://github.com/oktal/pistache/pull/620
      Fork: https://git.mobley.ne02ptzero.me/~louis/pistacheSigned-off-by: default avatarLouis Solofrizzo <lsolofrizzo@online.net>
      44e40478
  6. 16 Oct, 2019 2 commits
  7. 15 Oct, 2019 3 commits
  8. 08 Oct, 2019 2 commits
  9. 26 Sep, 2019 1 commit
  10. 25 Sep, 2019 1 commit
  11. 23 Sep, 2019 1 commit
  12. 22 Sep, 2019 1 commit
  13. 21 Sep, 2019 3 commits
  14. 20 Sep, 2019 1 commit
  15. 09 Sep, 2019 1 commit
  16. 07 Sep, 2019 6 commits
  17. 03 Sep, 2019 1 commit