Skip to content

Commit

Permalink
chore(volo-http): add feature json-utf8-lossy
Browse files Browse the repository at this point in the history
Since `sonic-rs` added a new feature `utf8_lossy`, it allows to parse
JSON with invalid UTF-8 and UTF-16 characters.

When this feature is enabled, invalid characters are replaced with
'\uFFFD' (displayed as �) instead of parsing failing due to invalid
characters.

Signed-off-by: Yu Li <[email protected]>
  • Loading branch information
yukiiiteru committed Nov 11, 2024
1 parent 9cd838e commit ef06352
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 62 deletions.
118 changes: 61 additions & 57 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ volo = { path = "../volo" }
volo-grpc = { path = "../volo-grpc", features = ["grpc-web"] }
volo-thrift = { path = "../volo-thrift", features = ["multiplex"] }
volo-http = { path = "../volo-http", features = [
"default_client",
"default_server",
"default-client",
"default-server",
"cookie",
] }

Expand Down
7 changes: 4 additions & 3 deletions volo-http/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ tokio-test.workspace = true
[features]
default = []

default_client = ["client", "json"]
default_server = ["server", "query", "form", "json", "multipart"]
default-client = ["client", "json"]
default-server = ["server", "query", "form", "json", "multipart"]

full = [
"client", "server", # core
"query", "form", "json", # serde
"tls", # https
"cookie", "multipart", "ws",
"cookie", "multipart", "ws", # exts
]

client = ["hyper/client", "hyper/http1"] # client core
Expand All @@ -110,6 +110,7 @@ __serde = ["dep:serde"] # a private feature for enabling `serde` by `serde_xxx`
query = ["__serde", "dep:serde_urlencoded"]
form = ["__serde", "dep:serde_urlencoded"]
json = ["__serde", "dep:sonic-rs"]
json-utf8-lossy = ["json", "sonic-rs/utf8_lossy"] # json feature

cookie = ["dep:cookie", "dep:cookie_store"]
multipart = ["dep:multer"]
Expand Down

0 comments on commit ef06352

Please sign in to comment.