@@ -426,19 +426,22 @@ fn response(
426
426
cookies : CookieJar ,
427
427
extension : Option < String > ,
428
428
config : & Data < Config > ,
429
+ redir : bool ,
429
430
) -> impl Responder {
430
431
let name = name. clone ( ) + & extension. map ( |e| format ! ( ".{e}" ) ) . unwrap_or_default ( ) ;
431
- HttpResponse :: Found ( )
432
- . append_header ( ( header:: LOCATION , name. clone ( ) ) )
433
- . cookie_delta ( & cookies)
434
- . body ( format ! (
435
- "{}{name}" ,
436
- if !config. base_url. is_empty( ) && !config. base_url. ends_with( '/' ) {
437
- format!( "{}{}" , config. base_url, "/" )
438
- } else {
439
- format!( "{}" , config. base_url)
440
- }
441
- ) )
432
+ let mut res = HttpResponse :: Ok ( ) ;
433
+ if redir {
434
+ res = HttpResponse :: Found ( ) ;
435
+ res. append_header ( ( header:: LOCATION , name. clone ( ) ) ) ;
436
+ }
437
+ res. cookie_delta ( & cookies) . body ( format ! (
438
+ "{}{name}" ,
439
+ if !config. base_url. is_empty( ) && !config. base_url. ends_with( '/' ) {
440
+ format!( "{}{}" , config. base_url, "/" )
441
+ } else {
442
+ format!( "{}" , config. base_url)
443
+ }
444
+ ) )
442
445
}
443
446
444
447
#[ post( "/" ) ]
@@ -450,7 +453,7 @@ async fn post_raw(
450
453
) -> Result < impl Responder > {
451
454
create_file ( payload, & database, & mut cookies, & config)
452
455
. await
453
- . map ( |it| response ( it, cookies, None , & config) )
456
+ . map ( |it| response ( it, cookies, None , & config, false ) )
454
457
}
455
458
456
459
fn is_form ( it : & GuardContext ) -> bool {
@@ -513,5 +516,6 @@ async fn post_form(
513
516
cookies,
514
517
extension,
515
518
& config,
519
+ true ,
516
520
) )
517
521
}
0 commit comments