Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F58932753
http_client.rs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
http_client.rs
View Options
//! Build a HTTP client with proper user agent.
use
std
::
collections
::
HashMap
;
use
ds_http_client
::{
parse_headers
,
Client
};
use
lazy_static
::
lazy_static
;
/* -------------------------------------------------------------
HTTP client
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
pub
fn
build_http_client
()
->
Client
{
let
mut
headers
=
HashMap
::
new
();
headers
.
insert
(
"User-Agent"
.
to_string
(),
get_user_agent
().
to_string
(),
);
let
headers
=
parse_headers
(
headers
);
Client
::
new
(
Some
(
headers
))
}
/* -------------------------------------------------------------
User agent
Compute at build time user agent to use in HTTP requests.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
lazy_static
!
{
pub
static
ref
USER_AGENT
:
String
=
format!
(
"{}/{} (https://databases.nasqueron.org/)"
,
env!
(
"CARGO_PKG_NAME"
),
env!
(
"CARGO_PKG_VERSION"
)
);
}
fn
get_user_agent
()
->
&
'
static
str
{
&
USER_AGENT
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 6, 05:35 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4300936
Default Alt Text
http_client.rs (1 KB)
Attached To
Mode
rDS Nasqueron Datasources
Attached
Detach File
Event Timeline
Log In to Comment