Successful HTTP request
This commit is contained in:
parent
bcd5090ebd
commit
57da34b095
1 changed files with 10 additions and 9 deletions
19
src/main.rs
19
src/main.rs
|
@ -16,8 +16,7 @@ use xml::reader::{EventReader, XmlEvent};
|
||||||
fn publicise() {
|
fn publicise() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
async fn get_folder_contents(password: String, url_tail: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
async fn get_folder_contents(password: String, url_tail: &str) -> Result<reqwest::Response, Box<dyn std::error::Error>> {
|
|
||||||
debug!("Entering: get_folder_contents()");
|
debug!("Entering: get_folder_contents()");
|
||||||
let root_url = "https://theadamcooper.com";
|
let root_url = "https://theadamcooper.com";
|
||||||
let method = reqwest::Method::from_bytes(b"PROPFIND").unwrap();
|
let method = reqwest::Method::from_bytes(b"PROPFIND").unwrap();
|
||||||
|
@ -36,13 +35,15 @@ async fn get_folder_contents(password: String, url_tail: &str) -> Result<reqwest
|
||||||
<oc:share-types/>
|
<oc:share-types/>
|
||||||
</d:prop>
|
</d:prop>
|
||||||
</d:propfind>"#);
|
</d:propfind>"#);
|
||||||
let response = client.request(method, url)
|
let response_text = client.request(method, url)
|
||||||
.basic_auth("adam", Some(password))
|
.basic_auth("adam", Some(password))
|
||||||
.body(body)
|
.body(body)
|
||||||
.send()
|
.send()
|
||||||
|
.await?
|
||||||
|
.text()
|
||||||
.await?;
|
.await?;
|
||||||
debug!("{:?}", response);
|
debug!("{:?}", response_text);
|
||||||
Ok(response)
|
Ok(response_text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_password() -> Result<String, std::io::Error> {
|
fn get_password() -> Result<String, std::io::Error> {
|
||||||
|
@ -57,13 +58,13 @@ fn get_password() -> Result<String, std::io::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> std::io::Result<()> {
|
||||||
env_logger::Builder::from_env(Env::default().default_filter_or("trace")).target(Target::Stdout).init();
|
env_logger::Builder::from_env(Env::default().default_filter_or("trace")).target(Target::Stdout).init();
|
||||||
println!("Publicise it!");
|
println!("Publicise it!");
|
||||||
let password = get_password().unwrap();
|
let password = get_password().unwrap().trim().to_string();
|
||||||
debug!("Received password: {}", password);
|
debug!("Received password: {}[END]", password);
|
||||||
|
|
||||||
let folder_contents = get_folder_contents(password, "/nextcloud/remote.php/dav/files/adam/public").await?;
|
let folder_contents = get_folder_contents(password, "/nextcloud/remote.php/dav/files/adam/public").await;
|
||||||
debug!("{:?}", folder_contents);
|
debug!("{:?}", folder_contents);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue