aboutsummaryrefslogtreecommitdiffstats
path: root/rs
diff options
context:
space:
mode:
Diffstat (limited to 'rs')
-rw-r--r--rs/server/src/main.rs29
1 files changed, 24 insertions, 5 deletions
diff --git a/rs/server/src/main.rs b/rs/server/src/main.rs
index 7060b15..b8428cb 100644
--- a/rs/server/src/main.rs
+++ b/rs/server/src/main.rs
@@ -287,11 +287,14 @@ enum GitLfsJsonRejection {
287 287
288impl IntoResponse for GitLfsJsonRejection { 288impl IntoResponse for GitLfsJsonRejection {
289 fn into_response(self) -> Response { 289 fn into_response(self) -> Response {
290 make_error_resp( 290 match self {
291 StatusCode::UNSUPPORTED_MEDIA_TYPE, 291 Self::Json(rej) => rej.into_response(),
292 &format!("Expected request with `Content-Type: {LFS_MIME}`"), 292 Self::MissingGitLfsJsonContentType => make_error_resp(
293 ) 293 StatusCode::UNSUPPORTED_MEDIA_TYPE,
294 .into_response() 294 &format!("Expected request with `Content-Type: {LFS_MIME}`"),
295 )
296 .into_response(),
297 }
295 } 298 }
296} 299}
297 300
@@ -944,3 +947,19 @@ async fn obj_download(
944 947
945 (headers, body).into_response() 948 (headers, body).into_response()
946} 949}
950
951#[test]
952fn test_mimetype() {
953 assert!(is_git_lfs_json_mimetype("application/vnd.git-lfs+json"));
954 assert!(!is_git_lfs_json_mimetype("application/vnd.git-lfs"));
955 assert!(!is_git_lfs_json_mimetype("application/json"));
956 assert!(is_git_lfs_json_mimetype(
957 "application/vnd.git-lfs+json; charset=utf-8"
958 ));
959 assert!(is_git_lfs_json_mimetype(
960 "application/vnd.git-lfs+json; charset=UTF-8"
961 ));
962 assert!(!is_git_lfs_json_mimetype(
963 "application/vnd.git-lfs+json; charset=ISO-8859-1"
964 ));
965}