parent
9f399b0440
commit
07686e693c
|
@ -95,7 +95,7 @@ async fn handle_http_response (
|
||||||
{
|
{
|
||||||
println! ("Step 6");
|
println! ("Step 6");
|
||||||
let (parts, body) = req.into_parts ();
|
let (parts, body) = req.into_parts ();
|
||||||
let resp_parts: http_serde::ResponseParts = rmp_serde::from_read_ref (&base64::decode (parts.headers.get ("X-PTTH-2LJYXWC4").unwrap ()).unwrap ()).unwrap ();
|
let resp_parts: http_serde::ResponseParts = rmp_serde::from_read_ref (&base64::decode (parts.headers.get (ptth::PTTH_MAGIC_HEADER).unwrap ()).unwrap ()).unwrap ();
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut watchers = state.watchers.lock ().await;
|
let mut watchers = state.watchers.lock ().await;
|
||||||
|
|
|
@ -14,7 +14,8 @@ use tokio::{
|
||||||
|
|
||||||
use ptth::http_serde;
|
use ptth::http_serde;
|
||||||
|
|
||||||
const SERVER_URL: &str = "http://127.0.0.1:4000";
|
const RELAY_URL: &str = "http://127.0.0.1:4000";
|
||||||
|
const SERVER_NAME: &str = "alien_wildlands";
|
||||||
|
|
||||||
async fn handle_req_resp (
|
async fn handle_req_resp (
|
||||||
client: &Client,
|
client: &Client,
|
||||||
|
@ -39,8 +40,8 @@ async fn handle_req_resp (
|
||||||
let response = ptth::file_server::serve_all (parts).await;
|
let response = ptth::file_server::serve_all (parts).await;
|
||||||
|
|
||||||
let mut resp_req = client
|
let mut resp_req = client
|
||||||
.post (&format! ("{}/http_response/{}", SERVER_URL, req_id))
|
.post (&format! ("{}/http_response/{}", RELAY_URL, req_id))
|
||||||
.header ("X-PTTH-2LJYXWC4", base64::encode (rmp_serde::to_vec (&response.parts).unwrap ()));
|
.header (ptth::PTTH_MAGIC_HEADER, base64::encode (rmp_serde::to_vec (&response.parts).unwrap ()));
|
||||||
|
|
||||||
if let Some (body) = response.body {
|
if let Some (body) = response.body {
|
||||||
resp_req = resp_req.body (body);
|
resp_req = resp_req.body (body);
|
||||||
|
@ -65,7 +66,7 @@ async fn main () -> Result <(), Box <dyn Error>> {
|
||||||
delay_for (Duration::from_millis (backoff_delay)).await;
|
delay_for (Duration::from_millis (backoff_delay)).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
let req_req = client.get ("http://127.0.0.1:4000/http_listen/alien_wildlands");
|
let req_req = client.get (&format! ("{}/http_listen/{}", RELAY_URL, SERVER_NAME));
|
||||||
|
|
||||||
let req_resp = match req_req.send ().await {
|
let req_resp = match req_req.send ().await {
|
||||||
Err (e) => {
|
Err (e) => {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
pub mod file_server;
|
pub mod file_server;
|
||||||
pub mod http_serde;
|
pub mod http_serde;
|
||||||
pub mod watcher;
|
pub mod watcher;
|
||||||
|
|
||||||
|
pub const PTTH_MAGIC_HEADER: &str = "X-PTTH-2LJYXWC4";
|
||||||
|
|
Loading…
Reference in New Issue