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() {
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
async fn get_folder_contents(password: String, url_tail: &str) -> Result<reqwest::Response, Box<dyn std::error::Error>> {
|
||||
async fn get_folder_contents(password: String, url_tail: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||
debug!("Entering: get_folder_contents()");
|
||||
let root_url = "https://theadamcooper.com";
|
||||
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/>
|
||||
</d:prop>
|
||||
</d:propfind>"#);
|
||||
let response = client.request(method, url)
|
||||
let response_text = client.request(method, url)
|
||||
.basic_auth("adam", Some(password))
|
||||
.body(body)
|
||||
.send()
|
||||
.await?
|
||||
.text()
|
||||
.await?;
|
||||
debug!("{:?}", response);
|
||||
Ok(response)
|
||||
debug!("{:?}", response_text);
|
||||
Ok(response_text)
|
||||
}
|
||||
|
||||
fn get_password() -> Result<String, std::io::Error> {
|
||||
|
@ -57,13 +58,13 @@ fn get_password() -> Result<String, std::io::Error> {
|
|||
}
|
||||
|
||||
#[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();
|
||||
println!("Publicise it!");
|
||||
let password = get_password().unwrap();
|
||||
debug!("Received password: {}", password);
|
||||
let password = get_password().unwrap().trim().to_string();
|
||||
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);
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue