MCPcopy Create free account
hub / github.com/AandStep/ResultV / parseSubscriptionUserInfoHeader

Function parseSubscriptionUserInfoHeader

app.go:1522–1550  ·  view source on GitHub ↗
(v string)

Source from the content-addressed store, hash-verified

1520}
1521
1522func parseSubscriptionUserInfoHeader(v string) (upload, download, total, expire int64) {
1523 if v == "" {
1524 return 0, 0, 0, 0
1525 }
1526 for _, part := range strings.Split(v, ";") {
1527 part = strings.TrimSpace(part)
1528 kv := strings.SplitN(part, "=", 2)
1529 if len(kv) != 2 {
1530 continue
1531 }
1532 key := strings.TrimSpace(strings.ToLower(kv[0]))
1533 val := strings.TrimSpace(kv[1])
1534 n, err := strconv.ParseInt(val, 10, 64)
1535 if err != nil {
1536 continue
1537 }
1538 switch key {
1539 case "upload":
1540 upload = n
1541 case "download":
1542 download = n
1543 case "total":
1544 total = n
1545 case "expire":
1546 expire = n
1547 }
1548 }
1549 return upload, download, total, expire
1550}
1551
1552func parseSubscriptionHeaderText(v string) string {
1553 v = strings.TrimSpace(v)

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected