Commit 3a296204 authored by jan.koester's avatar jan.koester
Browse files

test

parent 5f4fc1ea
Loading
Loading
Loading
Loading
+31 −4
Original line number Diff line number Diff line
@@ -223,9 +223,30 @@ libhttppp::HttpClient::HttpClient(const HttpUrl& desturl, int vers)
    try {
      if(vers == 3) {
        if (!tryHttp3First()) {
          // HTTP/3 failed — fallback to HTTP/1.1 or HTTP/2
          // HTTP/3 failed: try HTTP/2 first, then HTTP/1.1.
          if (_url.getProtocol() == HttpUrl::HTTPS) {
            bool h2_ok = false;
            try {
              // Internal probe mode: advertise ALPN h2 only.
              _vers = 4;
              resetConnection();
              h2_ok = _isH2;
            } catch (...) {
              h2_ok = false;
            }
            if (h2_ok) {
              _vers = 2;
            } else {
              _cltsock.reset();
              _vers = 0;
              resetConnection();
            }
          } else {
            // Cleartext cannot negotiate ALPN; fall back directly.
            _vers = 0;
            resetConnection();
          }
        }
      } else {
        resetConnection();
      }
@@ -317,7 +338,10 @@ void libhttppp::HttpClient::resetConnection(){
    auto sslsock = std::make_unique<netplus::ssl>(certs,-1);

    // Advertise ALPN based on version preference
    if (_vers >= 1) {
    if (_vers >= 4) {
        sslsock->getTls().client_alpn_protocols =
          std::string("\x02h2", 3);
    } else if (_vers >= 1) {
        sslsock->getTls().client_alpn_protocols =
          std::string("\x02h2\x08http/1.1", 12);
    } else {
@@ -396,7 +420,10 @@ void libhttppp::HttpClient::reconnect(){
    auto sslsock = std::make_unique<netplus::ssl>(certs,-1);

    // Advertise ALPN based on version preference
    if (_vers >= 1) {
    if (_vers >= 4) {
        sslsock->getTls().client_alpn_protocols =
          std::string("\x02h2", 3);
    } else if (_vers >= 1) {
        sslsock->getTls().client_alpn_protocols =
          std::string("\x02h2\x08http/1.1", 12);
    } else {
+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ namespace libhttppp {
      netplus::x509cert _cert;
      int _recvTimeoutSec = 60;
      int _sendTimeoutSec = 30;
      int _vers = 2;  // HTTP version preference (0=h1 only, 1=h1+h2, 2=h2 preferred, 3=h3)
      int _vers = 2;  // HTTP version preference (0=h1 only, 1=h1+h2, 2=h2 preferred, 3=h3, 4=internal h2-only probe)

      // Response tracking (populated by _h1ReadResponse / _h2Request / _h3Request)
      int _lastStatusCode = 0;