energy/cef/cef-request.go

88 lines
2.8 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 23:21:44 +08:00
// Instance 实例
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 23:21:44 +08:00
r1, _, _ := imports.Proc(internale_CefRequest_IsReadOnly).Call(m.Instance())
return api.GoBool(r1)
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 23:21:44 +08:00
imports.Proc(internale_CefRequest_SetUrl).Call(m.Instance(), api.PascalStr(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 23:21:44 +08:00
imports.Proc(internale_CefRequest_SetMethod).Call(m.Instance(), api.PascalStr(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 23:21:44 +08:00
imports.Proc(internale_CefRequest_SetReferrer).Call(m.Instance(), api.PascalStr(referrerUrl), policy.ToPtr())
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 23:21:44 +08:00
imports.Proc(internale_CefRequest_SetFlags).Call(m.Instance(), flags.ToPtr())
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 23:21:44 +08:00
imports.Proc(internale_CefRequest_SetFirstPartyForCookies).Call(m.Instance(), api.PascalStr(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 23:21:44 +08:00
r1, _, _ := imports.Proc(internale_CefRequest_GetHeaderByName).Call(m.Instance(), api.PascalStr(name))
return api.GoStr(r1)
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 23:21:44 +08:00
imports.Proc(internale_CefRequest_SetHeaderByName).Call(m.Instance(), api.PascalStr(name), api.PascalStr(value), api.PascalBool(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 {
2023-02-26 23:21:44 +08:00
var result uintptr
imports.Proc(internale_CefRequest_GetHeaderMap).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
return &ICefStringMultiMap{instance: unsafe.Pointer(result)}
2022-10-04 13:21:05 +08:00
}
func (m *ICefRequest) SetHeaderMap(headerMap *ICefStringMultiMap) {
2023-02-26 23:21:44 +08:00
imports.Proc(internale_CefRequest_SetHeaderMap).Call(m.Instance(), headerMap.Instance())
}
2023-02-26 23:21:44 +08:00
func (m *ICefRequest) GetPostData() *ICefPostData {
var result uintptr
imports.Proc(internale_CefRequest_GetPostData).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
return &ICefPostData{instance: unsafe.Pointer(result)}
2022-10-04 13:21:05 +08:00
}
2023-02-26 23:21:44 +08:00
func (m *ICefRequest) SetPostData(value *ICefPostData) {
imports.Proc(internale_CefRequest_SetPostData).Call(m.Instance(), value.Instance())
}