mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-09 10:45:27 +00:00
net: webrtc/webrtchttp: Respect HTTP redirects
Properly follow redirect URL. Before new request would be made, but with original URL again. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1387>
This commit is contained in:
parent
d2e5cb43cc
commit
2aacc74a44
2 changed files with 18 additions and 20 deletions
|
@ -755,11 +755,7 @@ impl WhepSrc {
|
||||||
redirect_url.as_str()
|
redirect_url.as_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(err) =
|
self.do_post(sess_desc, redirect_url).await
|
||||||
wait_async(&self.canceller, self.do_post(sess_desc), timeout).await
|
|
||||||
{
|
|
||||||
self.handle_future_error(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(e) => self.raise_error(gst::ResourceError::Failed, e.to_string()),
|
Err(e) => self.raise_error(gst::ResourceError::Failed, e.to_string()),
|
||||||
}
|
}
|
||||||
|
@ -931,27 +927,30 @@ impl WhepSrc {
|
||||||
let sess_desc = WebRTCSessionDescription::new(WebRTCSDPType::Offer, offer_sdp.sdp());
|
let sess_desc = WebRTCSessionDescription::new(WebRTCSDPType::Offer, offer_sdp.sdp());
|
||||||
|
|
||||||
let timeout;
|
let timeout;
|
||||||
|
let endpoint;
|
||||||
|
|
||||||
{
|
{
|
||||||
let settings = self.settings.lock().unwrap();
|
let settings = self.settings.lock().unwrap();
|
||||||
timeout = settings.timeout;
|
timeout = settings.timeout;
|
||||||
|
endpoint =
|
||||||
|
reqwest::Url::parse(settings.whep_endpoint.as_ref().unwrap().as_str()).unwrap();
|
||||||
drop(settings);
|
drop(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = wait_async(&self.canceller, self.do_post(sess_desc), timeout).await {
|
if let Err(e) =
|
||||||
|
wait_async(&self.canceller, self.do_post(sess_desc, endpoint), timeout).await
|
||||||
|
{
|
||||||
self.handle_future_error(e);
|
self.handle_future_error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
async fn do_post(&self, offer: WebRTCSessionDescription) {
|
async fn do_post(&self, offer: WebRTCSessionDescription, endpoint: reqwest::Url) {
|
||||||
let auth_token;
|
let auth_token;
|
||||||
let endpoint;
|
|
||||||
let timeout;
|
let timeout;
|
||||||
|
|
||||||
{
|
{
|
||||||
let settings = self.settings.lock().unwrap();
|
let settings = self.settings.lock().unwrap();
|
||||||
endpoint =
|
|
||||||
reqwest::Url::parse(settings.whep_endpoint.as_ref().unwrap().as_str()).unwrap();
|
|
||||||
auth_token = settings.auth_token.clone();
|
auth_token = settings.auth_token.clone();
|
||||||
timeout = settings.timeout;
|
timeout = settings.timeout;
|
||||||
drop(settings);
|
drop(settings);
|
||||||
|
|
|
@ -546,27 +546,30 @@ impl WhipSink {
|
||||||
);
|
);
|
||||||
|
|
||||||
let timeout;
|
let timeout;
|
||||||
|
let endpoint;
|
||||||
|
|
||||||
{
|
{
|
||||||
let settings = self.settings.lock().unwrap();
|
let settings = self.settings.lock().unwrap();
|
||||||
timeout = settings.timeout;
|
timeout = settings.timeout;
|
||||||
|
endpoint =
|
||||||
|
reqwest::Url::parse(settings.whip_endpoint.as_ref().unwrap().as_str()).unwrap();
|
||||||
drop(settings);
|
drop(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Err(e) = wait_async(&self.canceller, self.do_post(offer_sdp), timeout).await {
|
if let Err(e) =
|
||||||
|
wait_async(&self.canceller, self.do_post(offer_sdp, endpoint), timeout).await
|
||||||
|
{
|
||||||
self.handle_future_error(e);
|
self.handle_future_error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_recursion]
|
#[async_recursion]
|
||||||
async fn do_post(&self, offer: gst_webrtc::WebRTCSessionDescription) {
|
async fn do_post(&self, offer: gst_webrtc::WebRTCSessionDescription, endpoint: reqwest::Url) {
|
||||||
let auth_token;
|
let auth_token;
|
||||||
let endpoint;
|
|
||||||
let timeout;
|
let timeout;
|
||||||
|
|
||||||
{
|
{
|
||||||
let settings = self.settings.lock().unwrap();
|
let settings = self.settings.lock().unwrap();
|
||||||
endpoint =
|
|
||||||
reqwest::Url::parse(settings.whip_endpoint.as_ref().unwrap().as_str()).unwrap();
|
|
||||||
auth_token = settings.auth_token.clone();
|
auth_token = settings.auth_token.clone();
|
||||||
timeout = settings.timeout;
|
timeout = settings.timeout;
|
||||||
drop(settings);
|
drop(settings);
|
||||||
|
@ -794,11 +797,7 @@ impl WhipSink {
|
||||||
redirect_url.as_str()
|
redirect_url.as_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Err(err) =
|
self.do_post(offer, redirect_url).await
|
||||||
wait_async(&self.canceller, self.do_post(offer), timeout).await
|
|
||||||
{
|
|
||||||
self.handle_future_error(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Err(e) => self.raise_error(gst::ResourceError::Failed, e.to_string()),
|
Err(e) => self.raise_error(gst::ResourceError::Failed, e.to_string()),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue