Skip to content

Feat: HTTP client supporting Brotli Content-Encoding#3675

Closed
chise0713 wants to merge 1 commit intoSagerNet:main-nextfrom
chise0713:main-next
Closed

Feat: HTTP client supporting Brotli Content-Encoding#3675
chise0713 wants to merge 1 commit intoSagerNet:main-nextfrom
chise0713:main-next

Conversation

@chise0713
Copy link
Copy Markdown

I found that brotli is already an indirect dependency, so this PR adds a support for Content-Encoding: br.

Tested by this example:

package main

import (
        "net/http"

        "github.com/andybalholm/brotli"
)

func main() {
        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
                data := `{"version":1,"rules":[{"domain_suffix":["alphabet.com"],"domain_keyword":["fitbit","google"]}]}`
                w.Header().Set("Content-Encoding", "br")
                w.Header().Set("Content-Type", "application/json")
                bw := brotli.NewWriter(w)
                defer bw.Close()
                bw.Write([]byte(data))
        })
        panic(http.ListenAndServe("127.0.0.1:1408", nil))
}

sing-box logs and config file:

./sing-box run -c test.json; cat test.json 
INFO[0000] network: updated default interface enp7s0, index 2
DEBUG[0000] router: updating rule-set test from URL: http://127.0.0.1:1408
INFO[0000] outbound/direct: outbound connection to 127.0.0.1:1408
INFO[0000] router: updated rule-set test
INFO[0000] sing-box started (0.00s)
^C{
  "route": {
    "rule_set": [
      {
        "type": "remote",
        "tag": "test",
        "format": "source",
        "url": "http://127.0.0.1:1408"
      }
    ]
  }
}

But it's only in rule_set_remote.go and router.go, and wrote by some random AI that's not me.

If this PR doesn't meet the standards, feel free to just close it.

@nekohasekai nekohasekai force-pushed the main-next branch 3 times, most recently from 5574973 to 99cad72 Compare January 28, 2026 08:56
@nekohasekai nekohasekai force-pushed the main-next branch 4 times, most recently from 7894bb2 to d14417d Compare March 3, 2026 13:21
@nekohasekai nekohasekai deleted the branch SagerNet:main-next March 9, 2026 03:57
@nekohasekai nekohasekai closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants