GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Send messages in chunks and not per character · PastureStack/host-api@973d782

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • exec
    • exec.go
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎exec/exec.go‎

Copy file name to clipboardExpand all lines: exec/exec.go
+14-14Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package exec
22

33
import (
4-
"bufio"
54
"encoding/base64"
65
"io"
76
"net/url"
@@ -70,20 +69,21 @@ func (h *ExecHandler) Handle(key string, initialMessage string, incomingMessages
7069
}(outputWriter)
7170

7271
go func(r *io.PipeReader) {
73-
scanner := bufio.NewScanner(r)
74-
scanner.Split(bufio.ScanRunes)
75-
for scanner.Scan() {
76-
data := scanner.Bytes()
77-
text := base64.StdEncoding.EncodeToString(data)
78-
message := common.Message{
79-
Key: key,
80-
Type: common.Body,
81-
Body: text,
72+
buffer := make([]byte, 4096, 4096)
73+
for {
74+
c, err := r.Read(buffer)
75+
if c > 0 {
76+
text := base64.StdEncoding.EncodeToString(buffer[:c])
77+
message := common.Message{
78+
Key: key,
79+
Type: common.Body,
80+
Body: text,
81+
}
82+
response <- message
83+
}
84+
if err != nil {
85+
break
8286
}
83-
response <- message
84-
}
85-
if err := scanner.Err(); err != nil {
86-
log.WithFields(log.Fields{"error": err}).Error("Error with the exec scanner.")
8787
}
8888
}(outputReader)
8989

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.