mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 19:50:15 +08:00
[assetServer] Make WebView request URL and RequestURI RFC and Go docs compliant (#2722)
* [v2 dev] Improve logging of external AssetHandler * [assetServer] Make WebView request URL and RequestURI RFC and Go docs conforme
This commit is contained in:
parent
4162f097f1
commit
8fd16d4be3
@ -46,7 +46,7 @@ func NewExternalAssetsHandler(logger Logger, options assetserver.Options, url *u
|
|||||||
proxy.ErrorHandler = func(rw http.ResponseWriter, r *http.Request, err error) {
|
proxy.ErrorHandler = func(rw http.ResponseWriter, r *http.Request, err error) {
|
||||||
if baseHandler != nil && errors.Is(err, errSkipProxy) {
|
if baseHandler != nil && errors.Is(err, errSkipProxy) {
|
||||||
if logger != nil {
|
if logger != nil {
|
||||||
logger.Debug("[ExternalAssetHandler] Loading '%s' failed, using original AssetHandler", r.URL)
|
logger.Debug("[ExternalAssetHandler] '%s' returned not found, using AssetHandler", r.URL)
|
||||||
}
|
}
|
||||||
baseHandler.ServeHTTP(rw, r)
|
baseHandler.ServeHTTP(rw, r)
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,6 +96,18 @@ func (d *AssetServer) processWebViewRequest(r webview.Request) {
|
|||||||
d.webviewRequestErrorHandler(uri, rw, fmt.Errorf("HTTP-Request: %w", err))
|
d.webviewRequestErrorHandler(uri, rw, fmt.Errorf("HTTP-Request: %w", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For server requests, the URL is parsed from the URI supplied on the Request-Line as stored in RequestURI. For
|
||||||
|
// most requests, fields other than Path and RawQuery will be empty. (See RFC 7230, Section 5.3)
|
||||||
|
req.URL.Scheme = ""
|
||||||
|
req.URL.Host = ""
|
||||||
|
req.URL.Fragment = ""
|
||||||
|
req.URL.RawFragment = ""
|
||||||
|
|
||||||
|
if url := req.URL; req.RequestURI == "" && url != nil {
|
||||||
|
req.RequestURI = url.String()
|
||||||
|
}
|
||||||
|
|
||||||
req.Header = header
|
req.Header = header
|
||||||
|
|
||||||
if req.RemoteAddr == "" {
|
if req.RemoteAddr == "" {
|
||||||
@ -103,10 +115,6 @@ func (d *AssetServer) processWebViewRequest(r webview.Request) {
|
|||||||
req.RemoteAddr = "192.0.2.1:1234"
|
req.RemoteAddr = "192.0.2.1:1234"
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.RequestURI == "" && req.URL != nil {
|
|
||||||
req.RequestURI = req.URL.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.ContentLength == 0 {
|
if req.ContentLength == 0 {
|
||||||
req.ContentLength, _ = strconv.ParseInt(req.Header.Get(HeaderContentLength), 10, 64)
|
req.ContentLength, _ = strconv.ParseInt(req.Header.Get(HeaderContentLength), 10, 64)
|
||||||
} else {
|
} else {
|
||||||
|
@ -14,9 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- AssetServer RequestURI and URL are now RFC and Go Docs compliant for server requests. This means Scheme, Host and Fragments are not provided anymore. Changed by @stffabi in [PR](https://github.com/wailsapp/wails/pull/2722)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Avoid app crashing when the Linux GTK key is empty by @aminya in [PR](https://github.com/wailsapp/wails/pull/2672)
|
- Avoid app crashing when the Linux GTK key is empty. Fixed by @aminya in [PR](https://github.com/wailsapp/wails/pull/2672)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
@ -27,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Now uses new `go-webview2` module. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2687).
|
- Now uses new `go-webview2` module. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2687).
|
||||||
- Changed styling of `doctor` command. Changed by @MarvinJWendt in [PR](https://github.com/wailsapp/wails/pull/2660)
|
- Changed styling of `doctor` command. Changed by @MarvinJWendt in [PR](https://github.com/wailsapp/wails/pull/2660)
|
||||||
- Enable HiDPI option by default in windows nsis installer by @5aaee9 in [PR](https://github.com/wailsapp/wails/pull/2694)
|
- Enable HiDPI option by default in windows nsis installer. Changed by @5aaee9 in [PR](https://github.com/wailsapp/wails/pull/2694)
|
||||||
|
|
||||||
## v2.5.1 - 2023-05-16
|
## v2.5.1 - 2023-05-16
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user