From d939d38c4f7a6c40146a91b858a9968b1a9eb3ae Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 21 Jun 2019 01:11:29 +1000 Subject: [PATCH] Implement HTTP/2 downgrade by default (#549) * Implement HTTP/2 downgrade by default to increase application stability when using curl >= 7.62 --- config | 1 + docs/USAGE.md | 6 ++++-- onedrive.1.in | 7 ++++++- src/config.d | 6 +++++- src/main.d | 4 ++++ src/onedrive.d | 9 +++++++-- 6 files changed, 27 insertions(+), 6 deletions(-) diff --git a/config b/config index 239a2e92..c1af5b12 100644 --- a/config +++ b/config @@ -18,6 +18,7 @@ # disable_upload_validation = "false" # enable_logging = "false" # force_http_11 = "false" +# force_http_2 = "false" # local_first = "false" # no_remote_delete = "false" # skip_symlinks = "false" diff --git a/docs/USAGE.md b/docs/USAGE.md index a57744e3..2709ebf6 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -23,7 +23,7 @@ skip_file = "~*|.~*|*.tmp" Do not use a skip_file entry of `.*` as this will prevent correct searching of local changes to process. ### Important - curl compatibility -If your system utilises curl >= 7.62.0 you may need to use `--force-http-1.1` in order for the client to work correctly due to changes in curl to prefer HTTP/2 over HTTP/1.1 by default. +If your system utilises curl >= 7.62.0 curl defaults to prefer HTTP/2 over HTTP/1.1 by default. If you wish to use HTTP/2 for some operations you will need to use the `--force-http-2` config option to enable otherwise all operations will use HTTP/1.1. ### First run :zap: After installing the application you must run it at least once from the terminal to authorize it. @@ -492,7 +492,9 @@ Options: --enable-logging Enable client activity to a separate log file --force-http-1.1 - Force the use of HTTP 1.1 for all operations + Force the use of HTTP/1.1 for all operations (DEPRECIATED) + --force-http-2 + Force the use of HTTP/2 for all operations where applicable --get-O365-drive-id ARG Query and return the Office 365 Drive ID for a given Office 365 SharePoint Shared Library --help -h diff --git a/onedrive.1.in b/onedrive.1.in index 576ee68b..69dda6c8 100644 --- a/onedrive.1.in +++ b/onedrive.1.in @@ -79,10 +79,15 @@ Enable client activity to a separate log file Configuration file key: \fBenable_logging\fP (default: \fBfalse\fP) .TP \fB\-\-force\-http\-1.1\fP -Force the use of HTTP 1.1 for all operations +Force the use of HTTP 1.1 for all operations (DEPRECIATED) .br Configuration file key: \fBforce_http_11\fP (default: \fBfalse\fP) .TP +\fB\-\-force\-http\-2\fP +Force the use of HTTP/2 for all operations where applicable +.br +Configuration file key: \fBforce_http_2\fP (default: \fBfalse\fP) +.TP \fB\-\-get\-O365\-drive\-id\fP ARG Query and return the Office 365 Drive ID for a given Office 365 SharePoint Shared Library .TP diff --git a/src/config.d b/src/config.d index a8ff5862..61d9f9cf 100644 --- a/src/config.d +++ b/src/config.d @@ -40,6 +40,7 @@ final class Config boolValues["disable_upload_validation"] = false; boolValues["enable_logging"] = false; boolValues["force_http_11"] = false; + boolValues["force_http_2"] = false; boolValues["local_first"] = false; boolValues["no_remote_delete"] = false; boolValues["skip_symlinks"] = false; @@ -210,8 +211,11 @@ final class Config "Enable client activity to a separate log file", &boolValues["enable_logging"], "force-http-1.1", - "Force the use of HTTP 1.1 for all operations", + "Force the use of HTTP/1.1 for all operations (DEPRECIATED)", &boolValues["force_http_11"], + "force-http-2", + "Force the use of HTTP/2 for all operations where applicable", + &boolValues["force_http_2"], "get-O365-drive-id", "Query and return the Office 365 Drive ID for a given Office 365 SharePoint Shared Library", &stringValues["get_o365_drive_id"], diff --git a/src/main.d b/src/main.d index 43c660f5..95aa5e9d 100644 --- a/src/main.d +++ b/src/main.d @@ -197,6 +197,10 @@ int main(string[] args) return EXIT_SUCCESS; } + if (cfg.getValueBool("force_http_11")) { + log.log("NOTE: The use of --force-http-1.1 is depreciated"); + } + log.vlog("Initializing the OneDrive API ..."); try { online = testNetwork(); diff --git a/src/onedrive.d b/src/onedrive.d index 5655e8fc..02ad937a 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -102,8 +102,13 @@ final class OneDriveApi // What version of HTTP protocol do we use? // Curl >= 7.62.0 defaults to http2 for a significant number of operations - if (cfg.getValueBool("force_http_11")) { - log.vdebug("Downgrading all HTTP operations to HTTP 1.1"); + if (cfg.getValueBool("force_http_2")) { + // Use curl defaults + log.vdebug("Upgrading all HTTP operations to HTTP/2 where applicable"); + } else { + // Downgrade curl by default due to silent exist issues when using http/2 + // See issue #501 for details and discussion + log.vdebug("Downgrading all HTTP operations to HTTP/1.1 by default"); // Downgrade to HTTP 1.1 - yes version = 2 is HTTP 1.1 http.handle.set(CurlOption.http_version,2); }