energy/cef/cef-response.go

127 lines
3.0 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 Response
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"
2023-02-27 09:15:37 +08:00
"unsafe"
2022-10-04 13:21:05 +08:00
)
2023-02-27 09:15:37 +08:00
// Instance 实例
func (m *ICefResponse) Instance() uintptr {
if m == nil {
return 0
}
return uintptr(m.instance)
}
2023-02-27 11:33:00 +08:00
func (m *ICefResponse) IsValid() bool {
if m == nil || m.instance == nil {
return false
}
return true
}
2023-02-20 14:42:17 +08:00
// IsReadOnly 是否只读
2022-10-04 13:21:05 +08:00
func (m *ICefResponse) IsReadOnly() bool {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return false
}
2023-02-27 09:15:37 +08:00
r1, _, _ := imports.Proc(internale_CefResponse_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 *ICefResponse) SetURL(url string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_SetURL).Call(m.Instance(), api.PascalStr(url))
2023-02-20 14:42:17 +08:00
}
// SetError 设置错误码
2022-10-04 13:21:05 +08:00
func (m *ICefResponse) SetError(error TCefErrorCode) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_SetError).Call(m.Instance(), error.ToPtr())
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetStatus 设置状态码
2022-10-04 13:21:05 +08:00
func (m *ICefResponse) SetStatus(status int32) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_SetStatus).Call(m.Instance(), uintptr(status))
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetStatusText 设置状态文本
2022-10-04 13:21:05 +08:00
func (m *ICefResponse) SetStatusText(statusText string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_SetStatusText).Call(m.Instance(), api.PascalStr(statusText))
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetMimeType mime类型
2022-10-04 13:21:05 +08:00
func (m *ICefResponse) SetMimeType(mimetype string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_SetMimeType).Call(m.Instance(), api.PascalStr(mimetype))
2022-10-04 13:21:05 +08:00
}
2023-02-20 14:42:17 +08:00
// SetCharset 设置编码
2022-10-04 13:21:05 +08:00
func (m *ICefResponse) SetCharset(charset string) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_SetCharset).Call(m.Instance(), api.PascalStr(charset))
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 *ICefResponse) GetHeaderByName(name string) string {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return ""
}
2023-02-27 09:15:37 +08:00
r1, _, _ := imports.Proc(internale_CefResponse_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 *ICefResponse) SetHeaderByName(name, value string, overwrite bool) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_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 *ICefResponse) GetHeaderMap() *ICefStringMultiMap {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return nil
}
2023-02-27 09:15:37 +08:00
var result uintptr
imports.Proc(internale_CefResponse_GetHeaderMap).Call(m.Instance(), uintptr(unsafe.Pointer(&result)))
return &ICefStringMultiMap{instance: unsafe.Pointer(result)}
2022-10-04 13:21:05 +08:00
}
2023-02-27 09:15:37 +08:00
// GetHeaderMap
func (m *ICefResponse) SetHeaderMap(headerMap *ICefStringMultiMap) {
2023-02-27 11:33:00 +08:00
if !m.IsValid() {
return
}
2023-02-27 09:15:37 +08:00
imports.Proc(internale_CefResponse_SetHeaderMap).Call(m.Instance(), headerMap.Instance())
2022-10-04 13:21:05 +08:00
}