1. 11 Nov, 2019 1 commit
    • Dimitrios Katsaros's avatar
      Transport: Workaround for segmentation fault · 79e1a118
      Dimitrios Katsaros authored
      There is a race condition where a connection being serviced can
      hang up before a write operation is performed. In these cases, the
      transport will issue an error response to the disconnected peer,
      which invokes a promise to handle the request. The object is destroyed
      and then the promise is resolved on the destroyed response object,
      causing a segmentation fault
      79e1a118
  2. 01 Nov, 2019 3 commits
  3. 29 Oct, 2019 4 commits
  4. 28 Oct, 2019 4 commits
  5. 18 Oct, 2019 6 commits
  6. 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
  7. 16 Oct, 2019 2 commits
  8. 15 Oct, 2019 3 commits
  9. 08 Oct, 2019 2 commits
  10. 26 Sep, 2019 1 commit
  11. 25 Sep, 2019 1 commit
  12. 23 Sep, 2019 1 commit
  13. 22 Sep, 2019 1 commit
  14. 21 Sep, 2019 3 commits
  15. 20 Sep, 2019 1 commit
  16. 09 Sep, 2019 1 commit
  17. 07 Sep, 2019 5 commits