I am trying to get the response out of the awc::client::ClientResponse. But always get the empty string. If I use the same request with curl I get the response. Here is what I am trying This is a actix_web service which accepts the json request and call other service to get the response. and then sends it back to the client.
async fn get_info(info: actix_web::web::Json<Info>) -> impl Responder {
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
builder.set_verify(SslVerifyMode::NONE);
let myconnector = builder.build();
let client = Client::builder()
.connector(Connector::new().ssl(myconnector).finish())
.finish();
let fund_card_req:FundingCardRequest = FundingCardRequest::new(vec![Accounts::new("45135612".to_string(), 666666)],
String::from("INCOMING"),
String::from("ACH"), 1095434517);
println!("{:?}", serde_json::to_string(&fund_card_req));
let mut response = client.post("https://mn.sit.jq.com/fundingcard-activity")
.timeout(core::time::Duration::from_secs(10))
.header("Content-Type", "application/json")
.send_json(&fund_card_req).await.unwrap();
match response.status(){
StatusCode::OK => {
println!("status: success");
let k = response.body().limit(20_000_000).await.unwrap();
println!("{:?}", str::from_utf8(&k));
},
_ => println!("status: failed"),
}
HttpResponse::Ok().body("hello world")
}
I have gone through most of the examples client examples on rust Following is my setup.
actix-web = {version ="3.3.2", features = ["openssl"]}
actix-service = "1.0.1"
openssl = "0.10.29"