mirror of
https://github.com/versity/versitygw.git
synced 2026-07-02 16:54:25 +00:00
4d391cabc8
Fixes #2180 Fixes #2181 Migrate the gateway from Fiber v2 to Fiber v3.3.0 and update the affected server, middleware, handler, controller, and test code for the new APIs. Replace the deprecated Fiber filesystem middleware used by the WebUI with the Fiber v3 static middleware, serving the embedded WebUI assets from an fs.Sub filesystem. Fix the request header limit handling regression by adding a temporary handler for Fiber v3/fasthttp small-buffer errors so oversized request headers return the expected regulated S3 error response. Fix the debuglogger panic by reworking the boxed key/value formatter used for debug request and response dumps. The formatter now handles long header keys and values without producing invalid wrap widths, negative padding, or out-of-range string slices.
61 lines
2.0 KiB
Go
61 lines
2.0 KiB
Go
// Copyright 2026 Versity Software
|
|
// This file is licensed under the Apache License, Version 2.0
|
|
// (the "License"); you may not use this file except in compliance
|
|
// with the License. You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing,
|
|
// software distributed under the License is distributed on an
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
// KIND, either express or implied. See the License for the
|
|
// specific language governing permissions and limitations
|
|
// under the License.
|
|
|
|
package s3err
|
|
|
|
import "encoding/xml"
|
|
|
|
// RequestHeaderSectionTooLargeError is returned when the full HTTP request
|
|
// header section exceeds the server read buffer.
|
|
// Produces a <MaxSizeAllowed> field in the XML response.
|
|
type RequestHeaderSectionTooLargeError struct {
|
|
APIError
|
|
MaxSizeAllowed int
|
|
}
|
|
|
|
func (e RequestHeaderSectionTooLargeError) XMLBody(requestID, hostID string) []byte {
|
|
return encodeResponse(struct {
|
|
XMLName xml.Name `xml:"Error"`
|
|
Code string
|
|
Message string
|
|
MaxSizeAllowed int `xml:",omitempty"`
|
|
RequestID string `xml:"RequestId,omitempty"`
|
|
HostID string `xml:"HostId,omitempty"`
|
|
}{
|
|
Code: e.Code,
|
|
Message: e.Description,
|
|
MaxSizeAllowed: e.MaxSizeAllowed,
|
|
RequestID: requestID,
|
|
HostID: hostID,
|
|
})
|
|
}
|
|
|
|
func (e RequestHeaderSectionTooLargeError) HTMLBody(requestID, hostID string) []byte {
|
|
return e.APIError.encodeHTMLResponse(requestID, hostID,
|
|
ErrorField{Name: "MaxSizeAllowed", Value: e.MaxSizeAllowed},
|
|
)
|
|
}
|
|
|
|
func (e RequestHeaderSectionTooLargeError) Is(target error) bool {
|
|
t, ok := target.(APIError)
|
|
return ok && e.APIError == t
|
|
}
|
|
|
|
func GetRequestHeaderSectionTooLargeErr(maxSizeAllowed int) RequestHeaderSectionTooLargeError {
|
|
return RequestHeaderSectionTooLargeError{
|
|
APIError: GetAPIError(ErrRequestHeaderSectionTooLarge),
|
|
MaxSizeAllowed: maxSizeAllowed,
|
|
}
|
|
}
|