Implement HTTP/2 downgrade by default (#549)

* Implement HTTP/2 downgrade by default to increase application stability when using curl >= 7.62
This commit is contained in:
abraunegg 2019-06-21 01:11:29 +10:00 committed by GitHub
parent bb2986b222
commit d939d38c4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 6 deletions

1
config
View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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"],

View file

@ -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();

View file

@ -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);
}