github.com/AlpineAIO/wails/v2@v2.0.0-beta.32.0.20240505041856-1047a8fa5fef/pkg/assetserver/webview/webkit2_legacy.go (about) 1 //go:build linux && !(webkit2_36 || webkit2_40) 2 3 package webview 4 5 /* 6 #cgo linux pkg-config: gtk+-3.0 webkit2gtk-4.0 7 8 #include "gtk/gtk.h" 9 #include "webkit2/webkit2.h" 10 */ 11 import "C" 12 13 import ( 14 "fmt" 15 "io" 16 "net/http" 17 "unsafe" 18 ) 19 20 const Webkit2MinMinorVersion = 0 21 22 func webkit_uri_scheme_request_get_http_method(_ *C.WebKitURISchemeRequest) string { 23 return http.MethodGet 24 } 25 26 func webkit_uri_scheme_request_get_http_headers(_ *C.WebKitURISchemeRequest) http.Header { 27 // Fake some basic default headers that are needed if e.g. request are being proxied to the an external sever, like 28 // we do in the devserver. 29 h := http.Header{} 30 h.Add("Accept", "*/*") 31 h.Add("User-Agent", "wails.io/605.1.15") 32 return h 33 } 34 35 func webkit_uri_scheme_request_get_http_body(_ *C.WebKitURISchemeRequest) io.ReadCloser { 36 return http.NoBody 37 } 38 39 func webkit_uri_scheme_request_finish(req *C.WebKitURISchemeRequest, code int, header http.Header, stream *C.GInputStream, streamLength int64) error { 40 if code != http.StatusOK { 41 return fmt.Errorf("StatusCodes not supported: %d - %s", code, http.StatusText(code)) 42 } 43 44 cMimeType := C.CString(header.Get(HeaderContentType)) 45 C.webkit_uri_scheme_request_finish(req, stream, C.gint64(streamLength), cMimeType) 46 C.free(unsafe.Pointer(cMimeType)) 47 return nil 48 }