Skip to content

Commit

Permalink
SplitHTTP: Fix wrong config deserialization (#3610)
Browse files Browse the repository at this point in the history
Testing was conducted only using explicit parameters, and using
testsuite. However, when the parameters are not explicitly set in JSON
config, it seems that `c.MaxUploadSize` will contain `RandRangeConfig {
From: 0, To: 0 }` instead of `nil`, which breaks upload entirely.
  • Loading branch information
mmmray authored Jul 29, 2024
1 parent 70383c5 commit 33daa0c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions transport/internet/splithttp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *Config) GetRequestHeader() http.Header {
}

func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfig {
if c.MaxConcurrentUploads == nil {
if c.MaxConcurrentUploads == nil || c.MaxConcurrentUploads.To == 0 {
if isServer {
return RandRangeConfig{
From: 200,
Expand All @@ -55,7 +55,7 @@ func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfi
}

func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig {
if c.MaxUploadSize == nil {
if c.MaxUploadSize == nil || c.MaxUploadSize.To == 0 {
if isServer {
return RandRangeConfig{
From: 2000000,
Expand All @@ -73,7 +73,7 @@ func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig {
}

func (c *Config) GetNormalizedMinUploadInterval() RandRangeConfig {
if c.MinUploadIntervalMs == nil {
if c.MinUploadIntervalMs == nil || c.MinUploadIntervalMs.To == 0 {
return RandRangeConfig{
From: 30,
To: 30,
Expand Down

0 comments on commit 33daa0c

Please sign in to comment.