Skip to content

Commit

Permalink
Revise
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Mar 5, 2025
1 parent 8730808 commit 06dcc1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1492,10 +1492,10 @@ impl Server {
return Ok(
r::content_response(
&server_config,
inscription,
inscription_id,
accept_encoding,
sec_fetch_dest,
inscription,
)?
.ok_or_not_found(|| format!("inscription {inscription_id} content"))?
.into_response(),
Expand Down
43 changes: 21 additions & 22 deletions src/subcommand/server/r.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ pub(super) async fn content(
Ok(
content_response(
&server_config,
inscription,
inscription_id,
accept_encoding,
sec_fetch_dest,
inscription,
)?
.ok_or_not_found(|| format!("inscription {inscription_id} content"))?
.into_response(),
Expand Down Expand Up @@ -293,11 +293,10 @@ impl IntoResponse for ContentResponse {

pub(crate) fn content_response(
server_config: &ServerConfig,
// todo: Swap these?
inscription: Inscription,
inscription_id: InscriptionId,
accept_encoding: AcceptEncoding,
sec_fetch_dest: SecFetchDest,
inscription: Inscription,
) -> ServerResult<Option<ContentResponse>> {
if sec_fetch_dest == SecFetchDest::Document {
return Ok(Some(ContentResponse {
Expand Down Expand Up @@ -649,10 +648,10 @@ pub(super) async fn undelegated_content(
Ok(
r::content_response(
&server_config,
inscription,
inscription_id,
accept_encoding,
sec_fetch_dest,
inscription,
)?
.ok_or_not_found(|| format!("inscription {inscription_id} content"))?
.into_response(),
Expand All @@ -668,14 +667,14 @@ mod tests {
fn content_response_no_content_type() {
let content_response = r::content_response(
&ServerConfig::default(),
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
Inscription {
content_type: None,
body: Some(Vec::new()),
..default()
},
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
)
.unwrap()
.unwrap();
Expand All @@ -688,14 +687,14 @@ mod tests {
fn content_response_bad_content_type() {
let content_response = r::content_response(
&ServerConfig::default(),
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
Inscription {
content_type: Some("\n".as_bytes().to_vec()),
body: Some(Vec::new()),
..Default::default()
},
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
)
.unwrap()
.unwrap();
Expand All @@ -708,14 +707,14 @@ mod tests {
fn content_response_no_content() {
assert!(r::content_response(
&ServerConfig::default(),
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
Inscription {
content_type: Some("text/plain".as_bytes().to_vec()),
body: None,
..default()
},
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
)
.unwrap()
.is_none());
Expand All @@ -725,14 +724,14 @@ mod tests {
fn content_response_with_content() {
let response = r::content_response(
&ServerConfig::default(),
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
Inscription {
content_type: Some("text/plain".as_bytes().to_vec()),
body: Some(vec![1, 2, 3]),
..default()
},
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
)
.unwrap()
.unwrap();
Expand All @@ -745,14 +744,14 @@ mod tests {
fn content_security_policy_no_origin() {
let response = r::content_response(
&ServerConfig::default(),
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
Inscription {
content_type: Some("text/plain".as_bytes().to_vec()),
body: Some(vec![1, 2, 3]),
..default()
},
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
)
.unwrap()
.unwrap();
Expand All @@ -770,14 +769,14 @@ mod tests {
csp_origin: Some("https://ordinals.com".into()),
..default()
},
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
Inscription {
content_type: Some("text/plain".as_bytes().to_vec()),
body: Some(vec![1, 2, 3]),
..default()
},
inscription_id(0),
AcceptEncoding::default(),
SecFetchDest::Other,
)
.unwrap()
.unwrap();
Expand Down

0 comments on commit 06dcc1d

Please sign in to comment.