Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Unified Diff: third_party/grpc/tools/http2_interop/http1frame.go

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/tools/http2_interop/http1frame.go
diff --git a/third_party/grpc/tools/http2_interop/http1frame.go b/third_party/grpc/tools/http2_interop/http1frame.go
new file mode 100644
index 0000000000000000000000000000000000000000..68ab197b6524a24b45a8ae14e59b33f64920d600
--- /dev/null
+++ b/third_party/grpc/tools/http2_interop/http1frame.go
@@ -0,0 +1,49 @@
+package http2interop
+
+import (
+ "bytes"
+ "io"
+ "strings"
+)
+
+// HTTP1Frame is not a real frame, but rather a way to represent an http1.x response.
+type HTTP1Frame struct {
+ Header FrameHeader
+ Data []byte
+}
+
+func (f *HTTP1Frame) GetHeader() *FrameHeader {
+ return &f.Header
+}
+
+func (f *HTTP1Frame) ParsePayload(r io.Reader) error {
+ var buf bytes.Buffer
+ if _, err := io.Copy(&buf, r); err != nil {
+ return err
+ }
+ f.Data = buf.Bytes()
+ return nil
+}
+
+func (f *HTTP1Frame) MarshalPayload() ([]byte, error) {
+ return []byte(string(f.Data)), nil
+}
+
+func (f *HTTP1Frame) MarshalBinary() ([]byte, error) {
+ buf, err := f.Header.MarshalBinary()
+ if err != nil {
+ return nil, err
+ }
+
+ buf = append(buf, f.Data...)
+
+ return buf, nil
+}
+
+func (f *HTTP1Frame) String() string {
+ s := string(f.Data)
+ parts := strings.SplitN(s, "\n", 2)
+ headerleft, _ := f.Header.MarshalBinary()
+
+ return strings.TrimSpace(string(headerleft) + parts[0])
+}
« no previous file with comments | « third_party/grpc/tools/http2_interop/goaway.go ('k') | third_party/grpc/tools/http2_interop/http2interop.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698