From 7ebe0b7d1f3661e0f9d17b2bd55314f3cb3b10d3 Mon Sep 17 00:00:00 2001 From: Krzysztof Zmij Date: Mon, 11 Dec 2023 21:24:35 +0100 Subject: [PATCH] 502 for acckz --- .../proxy/handler/RequestHandlerS3.scala | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/scala/com/ing/wbaa/rokku/proxy/handler/RequestHandlerS3.scala b/src/main/scala/com/ing/wbaa/rokku/proxy/handler/RequestHandlerS3.scala index eaecc0e9..6de8fd9d 100644 --- a/src/main/scala/com/ing/wbaa/rokku/proxy/handler/RequestHandlerS3.scala +++ b/src/main/scala/com/ing/wbaa/rokku/proxy/handler/RequestHandlerS3.scala @@ -2,19 +2,20 @@ package com.ing.wbaa.rokku.proxy.handler import akka.actor.ActorSystem import akka.http.scaladsl.Http +import akka.http.scaladsl.model.Uri.Path import akka.http.scaladsl.model._ import akka.http.scaladsl.model.headers.RawHeader import com.amazonaws.Request import com.amazonaws.auth.BasicAWSCredentials import com.ing.wbaa.rokku.proxy.config.StorageS3Settings -import com.ing.wbaa.rokku.proxy.data.{ RequestId, S3Request, User } +import com.ing.wbaa.rokku.proxy.data.{RequestId, S3Request, User} import com.ing.wbaa.rokku.proxy.handler.exception.RokkuThrottlingException import com.ing.wbaa.rokku.proxy.provider.aws.S3Client import com.ing.wbaa.rokku.proxy.provider.aws.SignatureHelpersCommon.awsVersion import com.ing.wbaa.rokku.proxy.queue.UserRequestQueue -import scala.concurrent.{ ExecutionContext, Future } -import scala.util.{ Failure, Success } +import scala.concurrent.{ExecutionContext, Future} +import scala.util.{Failure, Success} trait RequestHandlerS3 extends S3Client with UserRequestQueue { @@ -79,13 +80,19 @@ trait RequestHandlerS3 extends S3Client with UserRequestQueue { */ protected[this] def fireRequestToS3(request: HttpRequest)(implicit id: RequestId): Future[HttpResponse] = { logger.info(s"Request sent to backend storage: method: {} uri: {}, {}", request.method.value, request.uri.toString(), request) - Http() - .singleRequest(request) - .andThen { - case Success(r) => logger.info(s"Received response from backend storage: {}", r.status) - case Failure(exception) => logger.error("Backend error e={}", exception) + println(request.uri.path) + if(request.method == HttpMethods.PUT && request.uri.path.startsWith(Path("/acckz")) ) { + Future(HttpResponse.apply(StatusCodes.BadGateway, entity = HttpEntity(ContentTypes.`text/html(UTF-8)`, "\n502 Bad Gateway\n\n

502 Bad Gateway

\n
nginx/1.23.4
\n\n\n\n\n\n\n\n"))) + }else { + Http() + .singleRequest(request) + .andThen { + case Success(r) => logger.info(s"Received response from backend storage: {}", r.status) + case Failure(exception) => logger.error("Backend error e={}", exception) + } + .map(r => r.withEntity(r.entity.withoutSizeLimit())) } - .map(r => r.withEntity(r.entity.withoutSizeLimit())) + } /**