energy/cef/cef-request.go

121 lines
3.6 KiB
Go
Raw Normal View History

2022-10-04 13:21:05 +08:00
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
2022-10-04 13:21:05 +08:00
//
//----------------------------------------
2023-02-20 14:42:17 +08:00
// CEF Request
2022-10-04 13:21:05 +08:00
package cef
import (
"github.com/energye/energy/common/imports"
2022-10-04 22:34:57 +08:00
. "github.com/energye/energy/consts"
2022-10-04 13:21:05 +08:00
"github.com/energye/golcl/lcl/api"
"unsafe"
)
2023-02-26 19:14:49 +08:00
func (m *ICefRequest) Instance() uintptr {
return uintptr(m.instance)
}
2023-02-20 14:42:17 +08:00
// IsReadOnly 是否只读
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) IsReadOnly() bool {
2023-02-26 19:14:49 +08:00
return api.GoBool(cefRequest_IsReadOnly(m.Instance()))
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetURL 设置URL
func (m *ICefRequest) SetURL(url string) {
2023-02-26 19:14:49 +08:00
cefRequest_SetUrl(m.Instance(), url)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetMethod 设置请求方式
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetMethod(method string) {
2023-02-26 19:14:49 +08:00
cefRequest_SetMethod(m.Instance(), method)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetReferrer 设置来源策略
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetReferrer(referrerUrl string, policy TCefReferrerPolicy) {
2023-02-26 19:14:49 +08:00
cefRequest_SetReferrer(m.Instance(), referrerUrl, policy)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetFlags 设置请求标记
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetFlags(flags TCefUrlRequestFlags) {
2023-02-26 19:14:49 +08:00
cefRequest_SetFlags(m.Instance(), flags)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetFirstPartyForCookies
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetFirstPartyForCookies(url string) {
2023-02-26 19:14:49 +08:00
cefRequest_SetFirstPartyForCookies(m.Instance(), url)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// GetHeaderByName
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) GetHeaderByName(name string) string {
2023-02-26 19:14:49 +08:00
return api.GoStr(cefRequest_GetHeaderByName(m.Instance(), name))
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetHeaderByName
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) SetHeaderByName(name, value string, overwrite bool) {
2023-02-26 19:14:49 +08:00
cefRequest_SetHeaderByName(m.Instance(), name, value, overwrite)
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// GetHeaderMap
2022-10-04 13:21:05 +08:00
func (m *ICefRequest) GetHeaderMap() *ICefStringMultiMap {
headerMap := &ICefStringMultiMap{}
2023-02-26 19:14:49 +08:00
headerMap.instance = cefRequest_GetHeaderMap(m.Instance())
2022-10-04 13:21:05 +08:00
headerMap.ptr = unsafe.Pointer(headerMap.instance)
return headerMap
}
func (m *ICefRequest) SetHeaderMap(headerMap *ICefStringMultiMap) {
2023-02-26 19:14:49 +08:00
cefRequest_SetHeaderMap(m.Instance(), headerMap.instance)
}
// request
2022-10-04 13:21:05 +08:00
func cefRequest_IsReadOnly(instance uintptr) uintptr {
r1, _, _ := imports.Proc(internale_cefRequest_IsReadOnly).Call(instance)
2022-10-04 13:21:05 +08:00
return r1
}
func cefRequest_SetUrl(instance uintptr, url string) {
imports.Proc(internale_cefRequest_SetUrl).Call(instance, api.PascalStr(url))
2022-10-04 13:21:05 +08:00
}
func cefRequest_SetMethod(instance uintptr, method string) {
imports.Proc(internale_cefRequest_SetMethod).Call(instance, api.PascalStr(method))
2022-10-04 13:21:05 +08:00
}
func cefRequest_SetReferrer(instance uintptr, referrerUrl string, policy TCefReferrerPolicy) {
imports.Proc(internale_cefRequest_SetReferrer).Call(instance, api.PascalStr(referrerUrl), uintptr(policy))
2022-10-04 13:21:05 +08:00
}
func cefRequest_SetFlags(instance uintptr, flags TCefUrlRequestFlags) {
imports.Proc(internale_cefRequest_SetFlags).Call(instance, uintptr(flags))
2022-10-04 13:21:05 +08:00
}
func cefRequest_SetFirstPartyForCookies(instance uintptr, url string) {
imports.Proc(internale_cefRequest_SetFirstPartyForCookies).Call(instance, api.PascalStr(url))
2022-10-04 13:21:05 +08:00
}
func cefRequest_GetHeaderByName(instance uintptr, name string) uintptr {
r1, _, _ := imports.Proc(internale_cefRequest_GetHeaderByName).Call(instance, api.PascalStr(name))
2022-10-04 13:21:05 +08:00
return r1
}
func cefRequest_SetHeaderByName(instance uintptr, url, value string, overwrite bool) {
imports.Proc(internale_cefRequest_SetHeaderByName).Call(instance, api.PascalStr(url), api.PascalStr(value), api.PascalBool(overwrite))
2022-10-04 13:21:05 +08:00
}
func cefRequest_GetHeaderMap(instance uintptr) uintptr {
r1, _, _ := imports.Proc(internale_cefRequest_GetHeaderMap).Call(instance)
2022-10-04 13:21:05 +08:00
return r1
}
func cefRequest_SetHeaderMap(instance, headerMap uintptr) uintptr {
r1, _, _ := imports.Proc(internale_cefRequest_SetHeaderMap).Call(instance, headerMap)
return r1
}