Skip to content

Commit

Permalink
Merge pull request #2 from randomairborne/master
Browse files Browse the repository at this point in the history
Fix ureq tls
  • Loading branch information
Loudbooks authored Apr 15, 2024
2 parents 50daa37 + 9685f4f commit 5c9a96a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cpuid = "0.1.1"
whoami = "1.5.1"
machine-info = "1.0.6"
ureq = { version = "2.9.6", default-features = false, features = ["native-tls"] }
native-tls = "0.2.11"

[profile.release]
strip = true
Expand Down
9 changes: 8 additions & 1 deletion src/httphandler.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use native_tls::TlsConnector;
use std::io::Cursor;
use std::sync::Arc;
use ureq::{Agent, AgentBuilder};

pub struct HttpHandler {
pub url: String,
Expand All @@ -21,7 +24,11 @@ impl HttpHandler {
println!("Uploading your paste...");
let title = format!("{}'s ReportBook", name);

let result = ureq::post(&self.url)
let agent = AgentBuilder::new()
.tls_connector(Arc::new(TlsConnector::new().unwrap()))
.build();
let result = agent
.post(&self.url)
.set("content-type", "text/plain")
.set("title", title.as_str())
.send(Cursor::new(self.lines.join("\n")))
Expand Down

0 comments on commit 5c9a96a

Please sign in to comment.