Closed hplewis closed 2 years ago
It makes sense. TBD. Thanks!
It has been implemented in #52. Please use rsocket_rust_transport_websocket="0.7.3"
, here is a sample:
async fn test_client() {
let req: WebsocketRequest = WebsocketRequest::builder()
.uri("ws://127.0.0.1:8080/hello")
.header("x-foo-bar", "42")
.method("GET")
.body(())
.unwrap();
let tp = WebsocketClientTransport::from(req);
let c = RSocketFactory::connect()
.transport(tp)
.start()
.await
.expect("connect failed");
let res = c
.request_response(Payload::builder().set_data_utf8("foo").build())
.await
.expect("request failed")
.unwrap();
println!("response: {:?}", res);
}
@hplewis Please try it and feel free if you have any other questions. 😃
Thanks! I'll try it out tomorrow. :)
A bit awkward to respond a year and a half later, sorry. Got pulled away but back on this and can confirm it works! Thank you!
It would be good to support setting headers when using the WebsocketClientTransport. I imagine this would be done kinda like how the rsocket-java project does it, in that you can add any number of customer headers when setting up the connection, to be used when the connection is established.
Motivation
It would be useful to use this to create an rsocket client in rust which connects to an existing rsocket server that requires Authorization headers.
Desired solution
Either like:
or
I'd need to look a little closer to see which would make more sense.
Considered alternatives
None really that would make much sense.
Additional context
N/A