Proxy GUI pass (#793)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Gregory SchierandClaude Opus 5.5 authored and GitHub committed 2026-10-28 22:27:18 -07:00
1 parent 96ab0a8a60
commit e82ffc53ad
73 files changed
+6003 -1257

No files matched your search

+9 -16
View File
@@ -7,6 +7,7 @@ use crate::models::{Flow, find_header};
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use std::collections::BTreeMap;
use ts_rs::TS;
use yaak_models::models::{HttpRequest, HttpRequestHeader, HttpUrlParameter};
// The client's body types (`apps/yaak-client/lib/model_util.ts`).
@@ -28,16 +29,18 @@ const HOP_BY_HOP: &[&str] = &[
/// Yaak works these out itself when it sends the request.
const AUTOMATIC: &[&str] = &["host", "content-length", "accept-encoding"];
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export, export_to = "gen_rpc.ts")]
pub struct DroppedHeader {
pub name: String,
pub value: String,
pub reason: DropReason,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
#[serde(rename_all = "snake_case")]
#[ts(export, export_to = "gen_rpc.ts")]
pub enum DropReason {
/// Only meant for the hop between the app and the proxy.
HopByHop,
@@ -72,8 +75,8 @@ pub fn flow_to_request(flow: &Flow, body: &DecodedBody) -> Conversion {
));
}
// No name, as in Yaak, which then shows the URL.
let request = HttpRequest {
name: default_name(&url),
method: flow.method.clone(),
url,
url_parameters,
@@ -228,16 +231,6 @@ fn graphql_body(flow: &Flow, text: &str) -> Option<BTreeMap<String, Value>> {
Some(fields)
}
/// The path, or the host for a request to the root.
fn default_name(url: &str) -> String {
let rest = url.split_once("://").map_or(url, |(_, rest)| rest);
match rest.split_once('/') {
Some((_, path)) if !path.is_empty() => format!("/{path}"),
Some((host, _)) => host.to_string(),
None => rest.to_string(),
}
}
#[cfg(test)]
mod tests {
use super::*;
@@ -287,7 +280,7 @@ mod tests {
let r = &c.request;
assert_eq!(r.method, "GET");
assert_eq!(r.url, "https://api.github.com/search/issues");
assert_eq!(r.name, "/search/issues");
assert_eq!(r.name, "");
let params: Vec<(&str, &str)> =
r.url_parameters.iter().map(|p| (p.name.as_str(), p.value.as_str())).collect();
assert_eq!(params, vec![("q", "is:open label:bug"), ("per_page", "5")]);
@@ -391,7 +384,7 @@ mod tests {
{ "enabled": true, "name": "note", "value": "hello world!" },
])
);
assert_eq!(c.request.name, "/login");
assert_eq!(c.request.name, "", "unnamed, so Yaak shows its URL");
}
#[test]
@@ -412,7 +405,7 @@ mod tests {
let c = flow_to_request(&f, &body("hello"));
assert_eq!(c.request.body_type.as_deref(), Some("other"));
assert_eq!(c.request.body["text"], "hello");
assert_eq!(c.request.name, "x.test");
assert_eq!(c.request.name, "");
}
#[test]