Dear Gents,
I was creating a small proxy to intercept all local http requests, then
authorize them with the remote proxy. Here is the code snippet:
Source<IncomingConnection, CompletionStage<ServerBinding>> serverSource =
Http.get(system).bind(ConnectWithHttps.toHost("localhost",
LOCAL_PORT), materializer);
Authorization authorization = Authorization.basic(USERNAME,
PASSWORD);
Flow<HttpRequest, HttpRequest, NotUsed> applySecurity =
Flow.of(HttpRequest.class)
.map(request -> request.addHeader(authorization));
Flow<HttpRequest, HttpResponse,
CompletionStage<OutgoingConnection>> forwardToProxy =
Http.get(system).outgoingConnection(ConnectWithHttps.toHost(PROXY_ADDRESS,
PROXY_PORT));
Flow<HttpRequest, HttpResponse, NotUsed> handler =
Flow.of(HttpRequest.class)
.via(applySecurity)
.via(forwardToProxy);
serverSource.to(Sink.foreach(conn -> {
System.out.println("Accepted new connection from " +
conn.remoteAddress());
conn.handleWith(handler, materializer);
}
)).run(materializer);
I need to handle Https requests also. But I always get this error:
[WARN] [04/14/2016 00:07:28.480]
[MyActorSystem-akka.actor.default-dispatcher-13]
[akka.actor.ActorSystemImpl(MyActorSystem)] Illegal request, responding
with status '400 Bad Request': Request is missing required `Host` header:
'Host' header value of request to `eg.linkedin.com:443` doesn't match
request target authority: Host header: Some(Host: eg.linkedin.com:443)
I've tried to use "ConnectWithHttps" instead of "ConnectHttp" but it
didn't. I couldn't find any example related to Https
Any idea, thanks?
Regards,
Bassam
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.