diff --git a/cef/aux_viewsource.go b/cef/aux_viewsource.go index 0ae3fc27..7cdbf6ba 100644 --- a/cef/aux_viewsource.go +++ b/cef/aux_viewsource.go @@ -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 { diff --git a/cef/browser_window_lcl.go b/cef/browser_window_lcl.go index b8780d64..4426de8e 100644 --- a/cef/browser_window_lcl.go +++ b/cef/browser_window_lcl.go @@ -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) diff --git a/cef/browser_window_views_framework.go b/cef/browser_window_views_framework.go index 39da6ae8..11eb264b 100644 --- a/cef/browser_window_views_framework.go +++ b/cef/browser_window_views_framework.go @@ -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) diff --git a/cef/tray_views_frame_commponent_windows.go b/cef/tray_views_frame_commponent_windows.go index 07d05289..4dcdf444 100644 --- a/cef/tray_views_frame_commponent_windows.go +++ b/cef/tray_views_frame_commponent_windows.go @@ -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) { diff --git a/cef/types_string_multi_map.go b/cef/types_string_multi_map.go index 099e35ca..7279e4a4 100644 --- a/cef/types_string_multi_map.go +++ b/cef/types_string_multi_map.go @@ -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 }