()
| 106 | } |
| 107 | |
| 108 | func Example_headers() { |
| 109 | f := func(w http.ResponseWriter, r *http.Request) { |
| 110 | body, err := io.ReadAll(r.Body) |
| 111 | if err != nil { |
| 112 | panic(err) |
| 113 | } |
| 114 | if len(body) == 0 { |
| 115 | return |
| 116 | } |
| 117 | var ( |
| 118 | hdr transport.ObjHdr |
| 119 | hlen, off int |
| 120 | ) |
| 121 | for { |
| 122 | hlen = int(binary.BigEndian.Uint64(body[off:])) |
| 123 | off += 16 // hlen and hlen-checksum |
| 124 | hdr = transport.ExtObjHeader(body[off:], hlen) |
| 125 | if !transport.ReservedOpcode(hdr.Opcode) { |
| 126 | fmt.Printf("%+v (%d)\n", hdr, hlen) |
| 127 | off += hlen + int(hdr.ObjAttrs.Size) |
| 128 | } else { |
| 129 | break |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | ts := httptest.NewServer(http.HandlerFunc(f)) |
| 135 | defer ts.Close() |
| 136 | |
| 137 | httpclient := transport.NewIntraDataClient() |
| 138 | stream := transport.NewObjStream(httpclient, ts.URL, cos.GenTie(), nil) |
| 139 | |
| 140 | sendText(stream, lorem, duis) |
| 141 | stream.Fin() |
| 142 | |
| 143 | // Output: |
| 144 | // {Bck:aws://@uuid#namespace/abc ObjName:X ObjAttrs:{Atime:663346294 Size:231 Ver:1 Cksum:xxhash[h1] CustomMD:map[]} Opaque:[] SID: Opcode:0} (69) |
| 145 | // {Bck:ais://abracadabra ObjName:p/q/s ObjAttrs:{Atime:663346294 Size:213 Ver:222222222222222222222222 Cksum:xxhash[h2] CustomMD:map[xx:11 yy:22]} Opaque:[49 50 51] SID: Opcode:0} (110) |
| 146 | } |
| 147 | |
| 148 | func sendText(stream *transport.Stream, txt1, txt2 string) { |
| 149 | var wg sync.WaitGroup |
nothing calls this directly
no test coverage detected