Closed auterium closed 1 year ago
Hi @auterium. Thanks for creating this issue. Shouldn't the grpc server send this header in its response? set_response_headers
just copies all the headers from web_sys::Response
to http::Response
.
The gRPC server is sending the headers properly, but what I found was that for some weird reason web_sys::Response
is not passing all headers received. As a test, I forked and modified the repo to be printing out the copied headers in set_response_headers
and only the content-type
header was present. Any other header was missing out, even if visible from debug tools. I tried adding some headers on the server that would start with x-
in the hopes of them not being filtered out, but no luck. Kind of stuck on where to continue looking as it's my first experience with wasm so I'm still familiarizing myself with the ecosystem
@auterium Can you post some sample server code here? Thanks.
Hi @devashishdxt sorry for the late reply. Here's a sample server code:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt::init();
let addr = "127.0.0.1:3000".parse().unwrap();
let greeter = MyGreeter::default();
let greeter = GreeterServer::new(greeter)
.send_compressed(CompressionEncoding::Gzip);
println!("GreeterServer listening on {}", addr);
Server::builder()
.accept_http1(true)
.layer(GrpcWebLayer::new())
.add_service(greeter)
.serve(addr)
.await?;
Ok(())
}
I think your original error was because of some missing things in client code or misconfigured cors layer. I've added gzip tests in the repository. Here is client and server code: https://github.com/devashishdxt/tonic-web-wasm-client/tree/main/test-suite/gzip.
Ref: #27
Hi, thanks a lot for supporting this crate, it's been really helpful for me!
While trying to use compressed transfers, I'm stumbling this error:
I've dug around a bit and found out that for some reason the browser's
fetch()
call is filtering out all response headers except thecontent-type
one, meaning that thegrpc-encoding
header is not being passed down totonic
, hence the error. If I force the header to be included withincrate::call::set_response_headers()
:Then the calls/streams work properly. Of course this is not ideal as it would break non-compressed calls/streams. Any thoughts on how to deal with this? Thanks a lot in advance!
How to reproduce:
server.rs
:yew_client.rs