Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-encode tenant unicode characters in rust SDK #493

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rs/src/contracts/tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the MIT license.
// Generated from ../../../cs/src/Contracts/Tunnel.cs

use chrono::{DateTime, Utc};
use crate::contracts::TunnelAccessControl;
use crate::contracts::TunnelEndpoint;
use crate::contracts::TunnelOptions;
use crate::contracts::TunnelPort;
use crate::contracts::TunnelStatus;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

Expand Down
2 changes: 1 addition & 1 deletion rs/src/contracts/tunnel_access_control_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the MIT license.
// Generated from ../../../cs/src/Contracts/TunnelAccessControlEntry.cs

use chrono::{DateTime, Utc};
use crate::contracts::TunnelAccessControlEntryType;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

// Data contract for an access control entry on a `Tunnel` or `TunnelPort`.
Expand Down
2 changes: 1 addition & 1 deletion rs/src/contracts/tunnel_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct TunnelPort {
// A client that connects to a tunnel (by ID or name) without specifying a port number
// will connect to the default port for the tunnel, if a default is configured. Or if
// the tunnel has only one port then the single port is the implicit default.
//
//
// Selection of a default port for a connection also depends on matching the
// connection to the port `TunnelPort.Protocol`, so it is possible to configure
// separate defaults for distinct protocols like `TunnelProtocol.Http` and
Expand Down
23 changes: 20 additions & 3 deletions rs/src/management/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ impl TunnelManagementClient {
) -> HttpResult<TunnelEndpoint> {
let mut url = self.build_tunnel_uri(
locator,
Some(&format!("{}/{}", ENDPOINTS_API_SUB_PATH, endpoint.id.as_deref().unwrap())),
Some(&format!(
"{}/{}",
ENDPOINTS_API_SUB_PATH,
endpoint.id.as_deref().unwrap()
)),
);
url.query_pairs_mut()
.append_pair("connectionMode", &endpoint.connection_mode.to_string());
Expand All @@ -180,7 +184,11 @@ impl TunnelManagementClient {
) -> HttpResult<TunnelRelayTunnelEndpoint> {
let mut url = self.build_tunnel_uri(
locator,
Some(&format!("{}/{}", ENDPOINTS_API_SUB_PATH, endpoint.base.id.as_deref().unwrap())),
Some(&format!(
"{}/{}",
ENDPOINTS_API_SUB_PATH,
endpoint.base.id.as_deref().unwrap()
)),
);
url.query_pairs_mut()
.append_pair("connectionMode", &endpoint.base.connection_mode.to_string());
Expand Down Expand Up @@ -458,7 +466,16 @@ impl TunnelManagementClient {
match get_policy_header_value() {
Ok(Some(policy_header_value)) => {
if let Ok(header_value) = HeaderValue::from_maybe_shared(policy_header_value) {
headers.insert("User-Agent-Policies", header_value);
let header_value_str = header_value
.to_str()
.unwrap()
.replace("%22", "")
.replace("%3B", ";");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already use the urlencoding module in this crate, you should be able to use it here: https://docs.rs/urlencoding/latest/urlencoding/#

headers.insert(
"User-Agent-Policies",
HeaderValue::from_str(&header_value_str).unwrap(),
);
log::info!("Headers: {:?}", headers);
} else {
log::error!("Invalid header value");
}
Expand Down
Loading