server: set user-agent when slurping, fixes /. bug
This commit is contained in:
@@ -44,6 +44,8 @@ use crate::{
|
|||||||
const NEWSREADER_TAG_PREFIX: &'static str = "News/";
|
const NEWSREADER_TAG_PREFIX: &'static str = "News/";
|
||||||
const NEWSREADER_THREAD_PREFIX: &'static str = "news:";
|
const NEWSREADER_THREAD_PREFIX: &'static str = "news:";
|
||||||
|
|
||||||
|
const USER_AGENT: &'static str = "letterbox news reader (letterbox-ua@xinu.tv)";
|
||||||
|
|
||||||
// TODO: figure out how to use Cow
|
// TODO: figure out how to use Cow
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
trait Transformer: Send + Sync {
|
trait Transformer: Send + Sync {
|
||||||
@@ -318,7 +320,8 @@ impl<'c> Transformer for SlurpContents<'c> {
|
|||||||
let body = if let Some(body) = cacher.get(link.as_str()) {
|
let body = if let Some(body) = cacher.get(link.as_str()) {
|
||||||
String::from_utf8_lossy(&body).to_string()
|
String::from_utf8_lossy(&body).to_string()
|
||||||
} else {
|
} else {
|
||||||
let resp = reqwest::get(link.as_str()).await?;
|
let client = reqwest::Client::builder().user_agent(USER_AGENT).build()?;
|
||||||
|
let resp = client.get(link.as_str()).send().await?;
|
||||||
let status = resp.status();
|
let status = resp.status();
|
||||||
if status.is_server_error() {
|
if status.is_server_error() {
|
||||||
error!("status error for {link}: {status}");
|
error!("status error for {link}: {status}");
|
||||||
|
|||||||
Reference in New Issue
Block a user