diff options
| author | mo khan <mo@mokhan.ca> | 2025-05-14 13:18:54 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-05-14 13:18:54 -0600 |
| commit | 4b2d609a0efcc1d9b2f1a08f954d067ad1d9cd1e (patch) | |
| tree | 0afacf9217b0569130da6b97d4197331681bf119 /vendor/github.com/playwright-community/playwright-go/writable_stream.go | |
| parent | ab373d1fe698cd3f53258c09bc8515d88a6d0b9e (diff) | |
test: use playwright to test out an OIDC login
Diffstat (limited to 'vendor/github.com/playwright-community/playwright-go/writable_stream.go')
| -rw-r--r-- | vendor/github.com/playwright-community/playwright-go/writable_stream.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/github.com/playwright-community/playwright-go/writable_stream.go b/vendor/github.com/playwright-community/playwright-go/writable_stream.go new file mode 100644 index 0000000..7f144b4 --- /dev/null +++ b/vendor/github.com/playwright-community/playwright-go/writable_stream.go @@ -0,0 +1,44 @@ +package playwright + +import ( + "encoding/base64" + "io" + "os" +) + +type writableStream struct { + channelOwner +} + +func (s *writableStream) Copy(file string) error { + f, err := os.OpenFile(file, os.O_RDONLY, 0) + if err != nil { + return err + } + defer f.Close() + + for { + buf := make([]byte, defaultCopyBufSize) + n, err := f.Read(buf) + if err != nil && err != io.EOF { + return err + } + if n == 0 { + break + } + _, err = s.channel.Send("write", map[string]interface{}{ + "binary": base64.StdEncoding.EncodeToString(buf[:n]), + }) + if err != nil { + return err + } + } + _, err = s.channel.Send("close") + return err +} + +func newWritableStream(parent *channelOwner, objectType string, guid string, initializer map[string]interface{}) *writableStream { + stream := &writableStream{} + stream.createChannelOwner(stream, parent, objectType, guid, initializer) + return stream +} |
