U: 修复CEF49(WinXP)设置http头

This commit is contained in:
杨红岩 2024-01-10 18:11:05 +08:00
parent 254932b2d5
commit 17d6d152b3
5 changed files with 43 additions and 15 deletions

View File

@ -43,7 +43,14 @@ func (m *ICefBrowser) createBrowserViewSource() {
}
if assetserve.AssetsServerHeaderKeyValue != "" {
viewSourceWindow.Chromium().SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *TCefReturnValue) {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
if application.IsSpecVer49() {
headerMap := request.GetHeaderMap()
headerMap.Append(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue)
request.SetHeaderMap(headerMap)
headerMap.Free()
} else {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
}
})
}
viewSourceWindow.Chromium().SetOnBeforePopup(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, beforePopupInfo *BeforePopupInfo, popupFeatures *TCefPopupFeatures, windowInfo *TCefWindowInfo, client *ICefClient, settings *TCefBrowserSettings, resultExtraInfo *ICefDictionaryValue, noJavascriptAccess *bool) bool {

View File

@ -897,7 +897,14 @@ func (m *LCLBrowserWindow) registerDefaultEvent() {
})
m.Chromium().SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *consts.TCefReturnValue) {
if assetserve.AssetsServerHeaderKeyValue != "" {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
if application.IsSpecVer49() {
headerMap := request.GetHeaderMap()
headerMap.Append(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue)
request.SetHeaderMap(headerMap)
headerMap.Free()
} else {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
}
}
if bwEvent.onBeforeResourceLoad != nil {
bwEvent.onBeforeResourceLoad(sender, browser, frame, request, callback, result, m)

View File

@ -370,7 +370,14 @@ func (m *ViewsFrameworkBrowserWindow) registerDefaultEvent() {
})
m.Chromium().SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *consts.TCefReturnValue) {
if assetserve.AssetsServerHeaderKeyValue != "" {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
if application.IsSpecVer49() {
headerMap := request.GetHeaderMap()
headerMap.Append(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue)
request.SetHeaderMap(headerMap)
headerMap.Free()
} else {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
}
}
if bwEvent.onBeforeResourceLoad != nil {
bwEvent.onBeforeResourceLoad(sender, browser, frame, request, callback, result, m)

View File

@ -108,7 +108,14 @@ func (m *ViewsFrameTray) registerChromiumEvent() {
})
m.trayWindow.Chromium().SetOnBeforeResourceLoad(func(sender lcl.IObject, browser *ICefBrowser, frame *ICefFrame, request *ICefRequest, callback *ICefCallback, result *consts.TCefReturnValue) {
if assetserve.AssetsServerHeaderKeyValue != "" {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
if application.IsSpecVer49() {
headerMap := request.GetHeaderMap()
headerMap.Append(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue)
request.SetHeaderMap(headerMap)
headerMap.Free()
} else {
request.SetHeaderByName(assetserve.AssetsServerHeaderKeyName, assetserve.AssetsServerHeaderKeyValue, true)
}
}
})
m.trayWindow.Chromium().SetOnBeforeClose(func(sender lcl.IObject, browser *ICefBrowser) {

View File

@ -69,20 +69,20 @@ func (m *ICefStringMultiMap) GetEnumerate(key string, index uint32) (r string) {
}
// GetKey 根据 index 获取key
func (m *ICefStringMultiMap) GetKey(index uint32) (r string) {
value := NewTString()
imports.Proc(def.StringMultimap_GetKey).Call(m.Instance(), uintptr(index), value.Instance())
r = value.Value()
value.Free()
return r
func (m *ICefStringMultiMap) GetKey(index uint32) (key string) {
tKey := NewTString()
imports.Proc(def.StringMultimap_GetKey).Call(m.Instance(), uintptr(index), tKey.Instance())
key = tKey.Value()
tKey.Free()
return
}
// GetValue 根据 index 获取value
func (m *ICefStringMultiMap) GetValue(index uint32) (r string) {
value := NewTString()
imports.Proc(def.StringMultimap_GetValue).Call(m.Instance(), uintptr(index), value.Instance())
r = value.Value()
value.Free()
func (m *ICefStringMultiMap) GetValue(index uint32) (value string) {
tValue := NewTString()
imports.Proc(def.StringMultimap_GetValue).Call(m.Instance(), uintptr(index), tValue.Instance())
value = tValue.Value()
tValue.Free()
return
}