[akka-user] Re: http proxy support

2016-11-02 Thread André
Hi,

this config was supported in Spray but wasn't yet ported over to akka-http.

> Based on what I've read so far I need to enable the configuration and 
then it should work with Http().singleRequest
> however it's not connecting through the proxy.

May I ask where you got that info from?

Cheers
André

On Monday, October 31, 2016 at 11:26:44 PM UTC+1, sub...@gmail.com wrote:
>
> I'm interested in proxying http requests with akka-http. Based on what 
> I've read so far I need to enable the configuration and then it should work 
> with Http().singleRequest
> however it's not connecting through the proxy. I have the following config 
> in application.conf
>
> akka.http {
>
> host-connection-pool {
>
>   client {
>
> proxy {
>
>   http {
>
> host = 127.0.0.1
>
> post = 
>
>   }
>
> }
>
>   }
>
> }
> }
>
> and following code
>
> val responseFuture: Future[HttpResponse] =
>   Http().singleRequest(HttpRequest(uri = "http://akka.io;))
>
>
> val response: HttpResponse = Await.result(responseFuture, Duration.Inf)
>
> println(response.status.intValue())
>
>
> SBT has
>
>
> libraryDependencies += "com.typesafe.akka" %% "akka-http-core" % "2.4.11"
> libraryDependencies += "com.typesafe.akka" %% "akka-http-experimental" % 
> "2.4.11"
>
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: akka.http.scaladsl.model.Uri's apply() methods should still take charset and mode parameters?

2016-10-12 Thread André
> The last comment there by 2beaucoup was exactly what I am asking here.

That's me BTW.

There's no reason one can't pick up on this with an issue/PR in 
akka/akka-http. ;)

Cheers
André

On Tuesday, October 11, 2016 at 7:39:57 PM UTC+2, Richard Imaoka wrote:
>
> Thank you, I was missing that discussion. The last comment there by 
> 2beaucoup was exactly what I am asking here.
> It seems the question was not answered yet?
>
> Thanks
>
> 2016年10月10日月曜日 17時16分24秒 UTC+9 André:
>>
>> Hi Richard!
>>
>> See [1] for the discussion related to your question.
>>
>> [1] https://github.com/akka/akka/pull/18715#discussion-diff-41831981
>>
>> Cheers
>> André
>>
>> On Sunday, October 9, 2016 at 6:49:23 PM UTC+2, Richard Imaoka wrote:
>>>
>>> Hi,
>>>
>>> While I was trying to work on akka/akka-http#276 
>>> <https://github.com/akka/akka-http/issues/276>, I noticed something 
>>> strange.
>>>
>>> After akka/akka#18479 <https://github.com/akka/akka/pull/18479> was 
>>> fixed (PR to fix #18479 = akka/akka#18715 
>>> <https://github.com/akka/akka/pull/18715>), now the following is 
>>> possible.
>>> Isn't it non-intuitive that you can specify Uri.ParsingMode twice - once 
>>> in Uri() and secondly in query() method?
>>>
>>>
>>> val uri = Uri("http://localhost?a^=b;, mode=Uri.ParsingMode.Relaxed)
>>>
>>> //prints Some(b)
>>> println(uri.query(mode=Uri.ParsingMode.Relaxed).get("a^"))
>>>
>>> //IllegalUriException: Illegal query: Invalid input '^',
>>> // expected '+', '=', query-char, 'EOI', '&' or pct-encoded
>>> // (line 1, column 2): a^=b
>>> println(uri.query(mode=Uri.ParsingMode.Strict).get("a^"))
>>>
>>>
>>>
>>>
>>> If parsing a query string should be deferred as in akka/akka#18479 
>>> <https://github.com/akka/akka/pull/18479>, should we not pass mode as well 
>>> as charset into akka.http.scaladsl.model.Uri companion object's apply() 
>>> methods?
>>>
>>> Thanks,
>>> Richard
>>>
>>>
>>>
>>>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: ('=') sign still not allowed in query string even with Uri.ParsingMode.Relaxed? (akka/akka#18479)

2016-10-12 Thread André
I know it's long but please read the full discussion in 
https://github.com/akka/akka/issues/18479.

The problem isn't the question mark but the double "=". That's why you get 
an IllegalUriException: Illegal query: Invalid input '='.

> will try to work on #276 if no one is picking it up yet

Excellent! :)

On Tuesday, October 11, 2016 at 7:34:40 PM UTC+2, Richard Imaoka wrote:
>
> Ah, I thought akka/akka#18479  <https://github.com/akka/akka/issues/18479>was 
> saying that "GROUP=10380?page=2" is a valid case for the relaxed mode 
> as RomanIakovlev said this.
>
> > I still think it's a workaround rather than proper solution though. 
> Question marks and equal signs are not prohibited inside the query. Just 
> sayin'.
>
> If that is still not allowed, and if you need your own parsing 
> implementation to allow that, then clarification in the documentation helps 
> us more, which akka/akka-http#276 
> <https://github.com/akka/akka-http/issues/276> is asking for. (will try 
> to work on #276 if no one is picking it up yet)
>
> Thanks
>
> 2016年10月10日月曜日 17時23分00秒 UTC+9 André:
>>
>> Hi Richard,
>>
>> "GROUP=10380?page=2" isn't a well formed query and therefore can't be 
>> parsed even in relaxed mode. akka/akka#18479 
>> <https://github.com/akka/akka/pull/18715> provides a way to prevent 
>> parsing of the query component and to just look at the raw query string. 
>> You can access your query via the queryString() method and parse it youself.
>>
>> HTH
>> André
>>
>> On Sunday, October 9, 2016 at 6:38:34 PM UTC+2, Richard Imaoka wrote:
>>>
>>> Hi,
>>>
>>> While I tried to work on akka/akka-http#276 
>>> <https://github.com/akka/akka-http/issues/276>, and looked at 
>>> akka/akka#18479 <https://github.com/akka/akka/pull/18715> (PR to fix 
>>> #18479 = akka/akka#18715 <https://github.com/akka/akka/pull/18715>), 
>>> I found that the following code:
>>>
>>> Query("GROUP=10380?page=2",mode = Uri.ParsingMode.Relaxed)
>>>
>>>
>>> throws an exception:
>>>
>>>   IllegalUriException: Illegal query: Invalid input '=', expected '+', 
>>> query-char, 'EOI', '&' or pct-encoded (line 1, column 17): GROUP=10380?page=
>>>
>>>
>>> Wasn't akka/akka#18479 <https://github.com/akka/akka/pull/18715> (PR=
>>> akka/akka#18715 <https://github.com/akka/akka/pull/18715>) intended to 
>>> make this a valid query string, with Uri.ParsingMode.Relaxed ?
>>>
>>>
>>> *Additional Info*
>>> 1. I looked for a test case for this.
>>> According to UriSpec.scala 
>>> <https://github.com/akka/akka-http/blob/b7f13dc36918c870662e5434b15a45ab94594c8e/akka-http-core/src/test/scala/akka/http/scaladsl/model/UriSpec.scala#L508L514>,
>>>  
>>> Uri("?a=b=c").query() is still invalid, although query() method has default 
>>> mode = Uri.ParsingMode.Relaxed.
>>>
>>>
>>> 2. I didn't fully understand how parsing works  but probably it's 
>>> because CharacterClases.scala 
>>> <https://github.com/akka/akka-http/blob/b7f13dc36918c870662e5434b15a45ab94594c8e/akka-http-core/src/main/scala/akka/http/impl/model/parser/CharacterClasses.scala#L51>
>>> defines:
>>>
>>>   val `relaxed-query-char` = VCHAR -- "%&=#"
>>>
>>> where ('=') is made invalid?
>>>
>>> UriParser has 
>>>
>>> private[this] val `query-char` = uriParsingMode match {
>>>   case Uri.ParsingMode.Strict  ⇒ `strict-query-char`
>>>   case Uri.ParsingMode.Relaxed ⇒ `relaxed-query-char`
>>> }
>>>
>>> where `relaxed-query-char` is defined as above.
>>>
>>> Thanks,
>>> Richard
>>>
>>>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: ('=') sign still not allowed in query string even with Uri.ParsingMode.Relaxed? (akka/akka#18479)

2016-10-10 Thread André
Hi Richard,

"GROUP=10380?page=2" isn't a well formed query and therefore can't be 
parsed even in relaxed mode. akka/akka#18479 
<https://github.com/akka/akka/pull/18715> provides a way to prevent parsing 
of the query component and to just look at the raw query string. You can 
access your query via the queryString() method and parse it youself.

HTH
André

On Sunday, October 9, 2016 at 6:38:34 PM UTC+2, Richard Imaoka wrote:
>
> Hi,
>
> While I tried to work on akka/akka-http#276 
> <https://github.com/akka/akka-http/issues/276>, and looked at 
> akka/akka#18479 <https://github.com/akka/akka/pull/18715> (PR to fix 
> #18479 = akka/akka#18715 <https://github.com/akka/akka/pull/18715>), 
> I found that the following code:
>
> Query("GROUP=10380?page=2",mode = Uri.ParsingMode.Relaxed)
>
>
> throws an exception:
>
>   IllegalUriException: Illegal query: Invalid input '=', expected '+', 
> query-char, 'EOI', '&' or pct-encoded (line 1, column 17): GROUP=10380?page=
>
>
> Wasn't akka/akka#18479 <https://github.com/akka/akka/pull/18715> (PR=
> akka/akka#18715 <https://github.com/akka/akka/pull/18715>) intended to 
> make this a valid query string, with Uri.ParsingMode.Relaxed ?
>
>
> *Additional Info*
> 1. I looked for a test case for this.
> According to UriSpec.scala 
> <https://github.com/akka/akka-http/blob/b7f13dc36918c870662e5434b15a45ab94594c8e/akka-http-core/src/test/scala/akka/http/scaladsl/model/UriSpec.scala#L508L514>,
>  
> Uri("?a=b=c").query() is still invalid, although query() method has default 
> mode = Uri.ParsingMode.Relaxed.
>
>
> 2. I didn't fully understand how parsing works  but probably it's 
> because CharacterClases.scala 
> <https://github.com/akka/akka-http/blob/b7f13dc36918c870662e5434b15a45ab94594c8e/akka-http-core/src/main/scala/akka/http/impl/model/parser/CharacterClasses.scala#L51>
> defines:
>
>   val `relaxed-query-char` = VCHAR -- "%&=#"
>
> where ('=') is made invalid?
>
> UriParser has 
>
> private[this] val `query-char` = uriParsingMode match {
>   case Uri.ParsingMode.Strict  ⇒ `strict-query-char`
>   case Uri.ParsingMode.Relaxed ⇒ `relaxed-query-char`
> }
>
> where `relaxed-query-char` is defined as above.
>
> Thanks,
> Richard
>
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: akka.http.scaladsl.model.Uri's apply() methods should still take charset and mode parameters?

2016-10-10 Thread André
Hi Richard!

See [1] for the discussion related to your question.

[1] https://github.com/akka/akka/pull/18715#discussion-diff-41831981

Cheers
André

On Sunday, October 9, 2016 at 6:49:23 PM UTC+2, Richard Imaoka wrote:
>
> Hi,
>
> While I was trying to work on akka/akka-http#276 
> <https://github.com/akka/akka-http/issues/276>, I noticed something 
> strange.
>
> After akka/akka#18479 <https://github.com/akka/akka/pull/18479> was fixed 
> (PR to fix #18479 = akka/akka#18715 
> <https://github.com/akka/akka/pull/18715>), now the following is possible.
> Isn't it non-intuitive that you can specify Uri.ParsingMode twice - once 
> in Uri() and secondly in query() method?
>
>
> val uri = Uri("http://localhost?a^=b;, mode=Uri.ParsingMode.Relaxed)
>
> //prints Some(b)
> println(uri.query(mode=Uri.ParsingMode.Relaxed).get("a^"))
>
> //IllegalUriException: Illegal query: Invalid input '^',
> // expected '+', '=', query-char, 'EOI', '&' or pct-encoded
> // (line 1, column 2): a^=b
> println(uri.query(mode=Uri.ParsingMode.Strict).get("a^"))
>
>
>
>
> If parsing a query string should be deferred as in akka/akka#18479 
> <https://github.com/akka/akka/pull/18479>, should we not pass mode as well as 
> charset into akka.http.scaladsl.model.Uri companion object's apply() methods?
>
> Thanks,
> Richard
>
>
>
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Akka Http Client - Encoding issue

2016-09-30 Thread André
Hi Srinaath,

I was wrong. There's no way to let the renderer produce such a URI on the 
wire. "+" doesn't get percent encoded and "%2b" gets double encoded as 
"%252b". See [1] for an explanation.

However, there's Raw-Request-Uri which you can use. See [2] for an example.

[1] https://github.com/spray/spray/issues/803
[2] 
https://github.com/akka/akka-http/blob/a6245b606eec7b8ba77a2dbc96cdc388de5450d6/akka-http-core/src/test/scala/akka/http/impl/engine/rendering/RequestRendererSpec.scala#L311-L319

Cheers
André

On Wednesday, September 28, 2016 at 3:30:51 PM UTC+2, Srinaath Thyagarjan 
wrote:
>
> Hi Andre,
>
> Thanks for your response. I will try that and see how that works.
>
> Thanks,
> Srinaath
>
> On Monday, September 19, 2016 at 7:43:11 AM UTC-5, André wrote:
>>
>> Hi Srinaath,
>>
>> does it work with 
>>
>>   "https://example.com/customers/~/profiles/dj2bQryHPCj4IVrc48xTPD 
>> hswk%2FqNWx LuUA0G2T6GLnyBVD6wC231IjgDBYJnt/preferences"
>>
>> ?
>>
>> Akka should replace the spaces with a "+" while a "+" as input will get 
>> encoded as "%2B".
>>
>> HTH
>> André
>>
>> Srinaath
>>
>> On Friday, September 16, 2016 at 5:56:16 PM UTC+2, Srinaath Thyagarajan 
>> wrote:
>>>
>>> I am trying to invoke a Rest API using akka http client using below code.
>>>
>>> val httpRequest = HttpRequest(
>>>   method  = HttpMethods.GET,
>>>
>>>
>>>   uri ="https://example.com/customers/~/profiles/ 
>>> <https://www.google.com/url?q=https%3A%2F%2Fexample.com%2Fcustomers%2F~%2Fprofiles%2F=D=1=AFQjCNG6z6l7ghxZsB3W5uY6uM63_u_ATQ>*dj2bQryHPCj4IVrc48xTPD%2Bhswk%2FqNWx%2BLuUA0G2T6GLnyBVD6wC231IjgDBYJnt*/preferences",
>>>
>>>   headers = 
>>> List(Accept(MediaRange(MediaTypes.`application/json`.withParams(Map("v" → 
>>> "3",
>>> RawHeader("Content-Type", "application/json;v=3"),
>>> RawHeader("Api-Key", "XYZ")
>>>   )
>>> )
>>>
>>> Http().singleRequest(httpRequest, GatewayHelper.connectionContext)
>>>
>>>
>>> Before the call goes out, when i check the httprequest.uri (through 
>>> debugger), there is a partial uri decoding that is happening (%2B changed 
>>> to +)  "https://example.com/customers/~/profiles/
>>> *dj2bQryHPCj4IVrc48xTPD+hswk%2FqNWx+LuUA0G2T6GLnyBVD6wC231IjgDBYJnt/preferences"*
>>>
>>> Because of this the API is returning an error. Unfortunately, there are 
>>> bunch or APIs that has this type of path variable . So not able to invoke 
>>> using akka-http . 
>>>
>>>
>>> I also tried setting the parsing mode to Relaxed hoping that it would 
>>> not tamper the path variable, but it didnt help either.
>>>
>>>
>>>  Uri.apply("https://example.com/customers/~/profiles/
>>> *dj2bQryHPCj4IVrc48xTPD%2Bhswk%2FqNWx%2BLuUA0G2T6GLnyBVD6wC231IjgDBYJnt*
>>> /preferences", Uri.ParsingMode.Relaxed)
>>>
>>>
>>> So, Is there option where we can make akka no modify this before making 
>>> the httprequest? 
>>>
>>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Akka Http Client - Encoding issue

2016-09-19 Thread André
Hi Srinaath,

does it work with 

  "https://example.com/customers/~/profiles/dj2bQryHPCj4IVrc48xTPD 
hswk%2FqNWx LuUA0G2T6GLnyBVD6wC231IjgDBYJnt/preferences"

?

Akka should replace the spaces with a "+" while a "+" as input will get 
encoded as "%2B".

HTH
André

Srinaath

On Friday, September 16, 2016 at 5:56:16 PM UTC+2, Srinaath Thyagarajan 
wrote:
>
> I am trying to invoke a Rest API using akka http client using below code.
>
> val httpRequest = HttpRequest(
>   method  = HttpMethods.GET,
>
>
>   uri ="https://example.com/customers/~/profiles/ 
> <https://www.google.com/url?q=https%3A%2F%2Fexample.com%2Fcustomers%2F~%2Fprofiles%2F=D=1=AFQjCNG6z6l7ghxZsB3W5uY6uM63_u_ATQ>*dj2bQryHPCj4IVrc48xTPD%2Bhswk%2FqNWx%2BLuUA0G2T6GLnyBVD6wC231IjgDBYJnt*/preferences",
>
>   headers = 
> List(Accept(MediaRange(MediaTypes.`application/json`.withParams(Map("v" → 
> "3",
> RawHeader("Content-Type", "application/json;v=3"),
> RawHeader("Api-Key", "XYZ")
>   )
> )
>
> Http().singleRequest(httpRequest, GatewayHelper.connectionContext)
>
>
> Before the call goes out, when i check the httprequest.uri (through 
> debugger), there is a partial uri decoding that is happening (%2B changed 
> to +)  "https://example.com/customers/~/profiles/
> *dj2bQryHPCj4IVrc48xTPD+hswk%2FqNWx+LuUA0G2T6GLnyBVD6wC231IjgDBYJnt/preferences"*
>
> Because of this the API is returning an error. Unfortunately, there are 
> bunch or APIs that has this type of path variable . So not able to invoke 
> using akka-http . 
>
>
> I also tried setting the parsing mode to Relaxed hoping that it would not 
> tamper the path variable, but it didnt help either.
>
>
>  Uri.apply("https://example.com/customers/~/profiles/
> *dj2bQryHPCj4IVrc48xTPD%2Bhswk%2FqNWx%2BLuUA0G2T6GLnyBVD6wC231IjgDBYJnt*
> /preferences", Uri.ParsingMode.Relaxed)
>
>
> So, Is there option where we can make akka no modify this before making 
> the httprequest? 
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: [Akka-HTTP] How do I not specify the charset?

2016-09-14 Thread André
Hi Derek,

to get an exact view of the raw incoming request I'd suggest to consult 
Wireshark. Akka's logRequest directive can show slightly different/adapted 
data.

HTH
André

On Tuesday, September 13, 2016 at 7:30:08 PM UTC+2, Derek Wyatt wrote:
>
> I was able to verify that this is breaking the app in question, but not 
> with Akka.  I merely added the charset to the request that was working, and 
> it broke.
>
> But I think I have a more fundamental problem: I can't see the raw request 
> that came in from the client.  It, of course, is only represented using the 
> Akka HTTP model and that model requires a charset for NonBinary 
> ContentTypes.  So, if I wanted to try and force the outgoing request (to 
> the server for which I am being a reverse-proxy) to match the incoming 
> request in this regard, I wouldn't have enough information to know that I 
> should do that.
>
> Is there any way to get at the raw HTTP request so I can inspect it?  I 
> think I need to see exactly how the client created it in the first place.
>
> On Tuesday, September 13, 2016 at 12:58:15 PM UTC-4, Derek Wyatt wrote:
>>
>> Hi guys,
>>
>> I've written a reverse-proxy with Akka-HTTP and I'm hitting a problem 
>> while trying to interact with an ASP.NET app.  The only interesting 
>> thing I can see is that without the proxy, the Content-Type is lacking a 
>> charset but the proxy adds charset=UTF-8.
>>
>> I can't find a way to replicate that using Akka HTTP.  I think we can all 
>> agree that the addition of charset=UTF-8 is the right thing to do, but in 
>> this case it may be causing us a problem and I'd like to force it to look 
>> the same.  The best I've gotten so far is a definition where it has 
>> 'charset=', which isn't quite right.
>>
>> Can this be done?
>>
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: How can I decode an HttpResponse

2016-08-25 Thread André
Hi Barrett,

you can try


Http()
  .singleRequest(...)
  .map(_.entity.dataBytes.via(Gzip.decoderFlow))

HTH,
André


On Thursday, August 25, 2016 at 9:41:14 AM UTC+2, Barrett Kern wrote:
>
> Hello,
>
> I am consuming a 3rd party API that returns gzipped JSON. I  So far I 
> cannot figure out how to decompress this response.  I found the directives 
> for encoding/decoding but it seems (to me) that those have to be used in 
> the routing dsl?   The high level use case I have is user makes a request 
> to my endpoint and then my application consumes some APIs and ultimately 
> returns some transformed data to the user. 
>
> Thanks,
> Barry
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: How to read XML inputstream (with SAX parser) received by akka-http?

2016-08-02 Thread André
Maybe you can add your use case 
to https://github.com/akka/akka/issues/16210.

On Tuesday, August 2, 2016 at 10:12:13 AM UTC+2, JY wrote:
>
> I am new with AKKA and AKKA HTTP.
>
> I have to write a HTTP server application that reads a lot very big XML 
> data flows (via HTTP PUT method) and parses this Data with a SAX parser.
>
> How can I do that with akka-http?
>
> Thanx in advance for your help.
>

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka TCP with Actors vs Akka Streams and Flows/Graphs

2016-07-26 Thread Jarl André Hübenthal
Has some developed an akka stream based TCP server where connections is 
kept open and frame delimited messages is pouring in, and is eventually 
stored somewhere in a database? It seems to be such a simple pattern that i 
am surprised to not find any examples for it. But maybe the world is not so 
simple, or maybe akka streams arent targeted for main stream development 
with semi complex business logic. I need session management, authentication 
(crude) and cross connection session buffer, where connections can connect, 
send a partial message, disconnect for some reason, reconnect and send the 
last part of the message. The first message is always an HELO message (or 
login message). I feel the actor way of doing it is too fragile and 
resource consuming. I have like a river dance of actors doing all the 
wiring to keep session buffer for each connection, store the data and also 
to make sure that each message is at least stored once (only once in fact 
since i use unique index on table).

Today I have:

ActorSystem1(ServerActor -> ConnectionActor * N -> SessionActor * N) -> 
ActorSystem2(BackendRouterActor -> BackendWorkerActor)

The ServerActor is where akka tcp sets up the the server, with host and 
port.

ConnectionActor is one per connection, and validates the first message 
received as a login message. If not a login message, disconnects. If valid 
login message, creates a new SessionActor or finds an existing one, and 
then passes all further messages to the SessionActor.

SessionActor is a persistent actor and keeps in its journal message buffer, 
last message received and message counter, and will process the buffer for 
each incoming message chunk. It searches with a tail recursive function 
(but I could also done look ahead) for messages that ends with delimiter, 
parses this messages into an Event object and sends this off to the 
BackendRouterActor.

BackendRouterActor is a persistent At least once delivery actor, that when 
receives an Event object persists it and sends it off to the worker. If not 
confirmed within a time limt, resends, as usual with ALOD.

I know there may be some weaknesses in this architecture, so general advice 
on the architecture would be great.

But my main question, drawn in direct or abstract lines, how can this be 
done with Akka Streams? 

I see three problems (things i dont know the solution for) with akka 
streams:

1) The cross connection session buffer and other parameters related to 
session
2) Connection authentication (HELO message, which must be specific format)
2) At least once delivery where all parsed events MUST be stored.

Someone who can shed some insight on possible solutions to these problems 
and the topic in general, how to convert such an actor based stateful app 
to akka streams?

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: How to use custom HTTP methods in akka-http

2016-06-17 Thread André
Hi,

you can create custom methods with HttpMethod.custom which you can then 
provide to the constructor of HttpRequest.

HTH
André

On Friday, June 17, 2016 at 9:38:05 AM UTC+2, zhonglin wu wrote:
>
> Hi all:
> I' m using akka-http, there is a service provide the "query" method I 
> have to use.
>
> How to extends HTTP methods in akka-http? 
>
> Thanks and regards,
> wuzhonglin
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: access to HttpRequest rendering layer to help support "batched" requests

2015-12-15 Thread André
I think it's better to follow up on this in the ticket.

On Sunday, December 13, 2015 at 7:38:21 PM UTC+1, Devon Miller wrote:
>
> The recommendation from https://github.com/akka/akka/issues/19062 is to 
> use a http Bidi to handle the rendering in a nice non-api exposing way. The 
> idea is to get a ByteString that is the result of the http layer rendering 
> a HttpRequest.
>
> You can do something like this to get a bidi flow:
>
> val cl = Http().clientLayer(Host("blah.com"))
> val noSslTls = SslTlsPlacebo.forScala
> val test1 = cl atop noSslTls join Flow[ByteString].map{x => 
> println(x.utf8String); x}
> val response = Source.single(HttpRequest()).via(test1).runWith(Sink.head)
>
> The out from running this is:
> GET / HTTP/1.1
> Host: blah.com
> User-Agent: akka-http/2.3.12
>
>
> response: Future[HttpResponse] = 
> scala.concurrent.impl.Promise$DefaultPromise@6159c8be
>
>
> But you really get back an exception for each HttpRequest you put into 
> this. The ByteString of the rendered body is on out1.
>
> Await.result(response, 1 second)
> akka.stream.scaladsl.One2OneBidiFlow$OutputTruncationException$
>
> So I need to turn-off 1/2 of the bidi or map or route around the out2 so 
> that I get a ByteString as an output from this bidi. 
>
> Is there anyway to do this? As soon as I do a join the out1 and in2 get 
> connected and there is no way to turn that off. I need to make sure that 
> 1/2 of the bidi never runs because I only care about the HttpRequest to 
> ByteString rendering.
>
>
>
>
>
>
>

-- 
>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Handling exception from an Actor in Http routing

2015-12-10 Thread André
Hi Charlie,

I think FutureDirectives.onSuccess() is what you're after.

Cheers
André

On Thursday, December 10, 2015 at 6:24:33 PM UTC+1, Charlie Evans wrote:
>
> Hi all,
>
> I would like to handle exceptions using:
>
> implicit def myExceptionHandler: ExceptionHandler =
>
> ExceptionHandler {
>
>   case e: Exception => complete(HttpResponse(InternalServerError, 
> entity = e.getMessage))
>
> }
>
>
> when my complete fails in my route. This works fine if I throw an 
> exception in the complete block directly. However, I use an Actor to handle 
> the request with
>
>
> entity(as[Thing]) { thing =>
>
>   complete {
>
>val handler = system.actorOf(Handler.props, "handler")
>
>(handler ? thing).mapTo[String]
>
>   }
>
> }
>
>
> If a request fails from an exception thrown in the Handler actor how do I 
> get that exception to propagate back to this point so myExceptionHandler 
> can deal with it?
>
>
> Thanks
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Getting an array of formFields

2015-12-08 Thread André
Oops, wrong list!

Just use .* (see 
http://doc.akka.io/docs/akka-stream-and-http-experimental/2.0-M2/scala/http/routing-dsl/directives/form-field-directives/formFields.html)

HTH
André

On Tuesday, December 8, 2015 at 10:17:07 AM UTC+1, André wrote:
>
> Hi Jacobus,
>
> it's currently not possible to extract a sequence of values with the 
> formFields directive. See this post[1] on how to extract all form fileds.
>
> FYI: akka-http recently added the * receptacle to extract sequences. [2]
>
> [1] https://groups.google.com/d/msg/spray-user/Uqp0C0hOMvQ/rxQy0crJ_70J
> [2] https://github.com/akka/akka/pull/17107
>
> Cheers
> André
>
>
> On Monday, December 7, 2015 at 11:24:50 PM UTC+1, Jacobus wrote:
>>
>> Hi guys,
>>
>> I receive message content from a monitoring device in a formal like this:
>>
>> POST /monitor/status HTTP/1.1   
>> Host: testingtesting.com 
>> Connection: 
>> Keep-Alive  
>> Content-Type: 
>> application/x-www-form-urlencoded 
>> Authorization: Basic cmVtb3RlX2 cmVtb3RlX2NsaWVudNsaWVud=
>>
>>
>> Content-Length: 78  
>>   
>>  
>>
>>
>> [0]=0004A38E5835;   
>> [1]=0004A3D3F18B;
>>
>>
>> [2]=0004A3D3F18B;
>>   
>>
>>
>> Now if there was only one reading, then I could just use:
>>
>> formFields('reading) { reading =>
>>   complete {
>> logger.debug("Monitoring data received: " + reading)
>> 
>>}
>>
>> But what is the best way to access an array of measurements like the ones 
>> above. Is there some sort of directive available for this?
>>
>> Thanks in advance. I hope there is someone out there who had a little 
>> more coffee than me.
>>
>> Kind regards,
>> Jacobus
>>
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: access to HttpRequest rendering layer to help support "batched" requests

2015-12-01 Thread André
Agreed that it would be nice to reuse 
HttpRequestRendererFactory.renderToSource in this case.

Could you open a ticket?

Cheers
André

On Tuesday, December 1, 2015 at 7:01:03 AM UTC+1, Devon Miller wrote:
>
> I looked more into this issue and found that to get the request to fully 
> render so I can append them into a multipart body, I needed to use internal 
> API, or at least, this is the only way I could figure it out quickly. You 
> just need to run the HttpRequests into the Flow defined below. The code 
> comes from OutgoingConnectionBlueprint.
>
> package akka.http.impl.engine.client
>
> import akka.http.impl.engine.rendering.HttpRequestRendererFactory
> import akka.http.impl.engine.rendering.RequestRenderingContext
> import akka.stream.scaladsl.Flow
> import akka.http.scaladsl.model.HttpRequest
> import akka.util.ByteString
> import mscrm._
> import akka.event._
> import akka.http.scaladsl.model.headers._
> import concurrent.ExecutionContext
> import akka.stream._
> import akka.actor._
>
>
> object RequestRenderer {
>
>   def renderRequestFlow(hostname: String)(implicit ec: ExecutionContext, 
> mat: Materializer, as: ActorSystem) = {
> 
> val log = Logging.getLogger(implicitly[ActorSystem], this)
> val hostHeader = Host(hostname)
> val requestRendererFactory = new HttpRequestRendererFactory(None, 128, 
> log)
>
> val requestRendering: Flow[HttpRequest, ByteString, Unit] = 
> Flow[HttpRequest]
>   .map(RequestRenderingContext(_, hostHeader))
>   
> .via(Flow[RequestRenderingContext].flatMapConcat(requestRendererFactory.renderToSource).named("renderer"))
>
> requestRendering
>   }
> }
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: access to HttpRequest rendering layer to help support "batched" requests

2015-11-30 Thread André
Hi Devon,

there's no need for customized rendering in this case. 
Marshalling/rendering for multipart entities is already available.

This example 
<https://gist.github.com/jrudolph/08d0d28e1eddcd64dbd0#file-testmultipartfileupload-scala-L78-L93>
 
should get you started. Just replace Source.single(...) with a Source that 
wraps a sequence of your custom body parts (e.g. by mapping your requests).

HTH
André

On Monday, November 30, 2015 at 4:17:36 AM UTC+1, Devon Miller wrote:
>
> In order to satisfy some odata v4 "batch" protocol requirements, I need to 
> render several requests into the payload of a specially formed request 
> (details here 
> <http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/part1-protocol/odata-v4.0-errata02-os-part1-protocol-complete.html#_Toc406398359>
> ).
>
> I noticed that the rendering infrastructure for requests is in a private 
> part of akka-http: akka.http.impl.engine.rendering.
>
> Is there a way to use the rendering infrastructure to obtain string 
> versions of the rendered HttpRequests so I can put them into the payload of 
> another request?
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: [akka-http] Java server with https

2015-11-13 Thread André
Hi Ricardo,

doesn't look like HttpsContext param is currently surfaced in the java 
DSL's bindRoute.

This should be discussed in a ticket.

Cheers
André

On Thursday, November 12, 2015 at 6:57:38 PM UTC+1, Ricardo Silva wrote:
>
> Hello,
>
> is it possible to have a server handling https connections while using the 
> routing api?
> Reading the docs, there is support for it in the low-level api but I can't 
> find it exposed while using the "routes dsl"...
>
> Thanks in advance!
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: [akka-http] java completeWith mapping future

2015-11-11 Thread André
Hi Benoit,

you should take a look 
at http://doc.akka.io/docs/akka/snapshot/java/futures.html#Future_is_a_Monad.

Mapper should solve your Problem.

Cheers
André

On Wednesday, November 11, 2015 at 12:01:05 PM UTC+1, Benoit Guillon wrote:
>
> Hi,
>
> I'm using akka http with Java DSL and I'm trying to handle a get request 
> with an actor and map my actor's response to the HTTP response as follows:
>
> private Route getTasksRoute(){
>return 
> path("tasks").route(pathEndOrSingleSlash().route(get(this.handleWith(
>   (ctx) -> ctx.completeWith(handleGetTask(ctx))
>;
> }
>
> private Future handleGetTask(RequestContext ctx){
>return Patterns.ask(actorSystem.actorFor("myActor"), buildMessage(), 
> 1000)
>.map(o -> ctx.completeAs(Jackson.json(), o), 
> ctx.executionContext());
> }
>
> This code does not compile in Java 8 because the API enforces to use scala 
> futures
>
> Error:(74, 17) java: method map in interface scala.concurrent.Future 
> cannot be applied to given types;
>   required: 
> scala.Function1<java.lang.Object,S>,scala.concurrent.ExecutionContext
>   found: (o)->ctx.c[...]), o),scala.concurrent.ExecutionContext
>   reason: cannot infer type-variable(s) S
> (argument mismatch; scala.Function1 is not a functional interface
>   multiple non-overriding abstract methods found in interface 
> scala.Function1)
>
> I could not find any relevant code example illustrating this use case in 
> java.
>
> Can you suggest a code pattern to illustrate how the completeWith method 
> is intended to be used in Java 8 in conjonction with actors' ask pattern ?
>
> Thanks for your help.
>
> Benoit
>
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Size limitation for data upload in akka http

2015-10-07 Thread André
Hi Daniel,

what error msg do you get? Have you tried 
increasing akka.http.server.parsing.max-content-length (reference 
<http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/scala/http/configuration.html>
)

https://github.com/akka/akka/issues/18533 could be related here and was 
recently fixed.

Cheers
André

On Wednesday, October 7, 2015 at 9:30:08 AM UTC+2, Daniel Bauer wrote:
>
> I'm using akka http to implement a REST service and that works fine except 
> for one case. The HTTP message parser has a limit on the message size. This 
> means that I cannot upload "large" data using a simple POST message, 
> extract the "entity.dataBytes" and write that to a file. Is there a way how 
> I can get access to a "raw" stream such that it also works with arbitrary 
> file sizes? The simplistic solution below doesn't work for large data (due 
> to the message size limitation):
>
>   val routes = {
> pathSingleSlash {
>   (post & extractRequest) { 
> request => {
>   val source = request.entity.dataBytes
>   val outFile = new File("/tmp/outfile.dat")
>   val sink = SynchronousFileSink.create(outFile)
>   val repl = source.runWith(sink).map(x => s"Finished uploading 
> ${x} bytes!")
>   onSuccess(repl) { repl =>
> complete(HttpResponse(status = StatusCodes.OK, entity = repl))
>   }
> }
>   }
> }
>   }
>
>   Http().bindAndHandle(routes, config.getString("http.interface"), 
> config.getInt("http.port"))
>
>
>

-- 
>>>>>>>>>>  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: [akka-http] Some questions about akka-http

2015-08-25 Thread André
Hi Leon,

please see the discussion re. chunking here 
https://github.com/akka/akka/pull/18144.

What's your use case?

Cheers,
André

On Tuesday, August 25, 2015 at 9:21:46 AM UTC+2, Leon Ma wrote:

 Hi,

 I have some general questions about akka-http:

 1. Is there any concrete samples that illustrate how to return chunked 
 response with akka-http?
 2. Does Route/Directives (high-level api) supports chunked response?


 Thanks
 Leon





-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: [akka-http] Some questions about akka-http

2015-08-25 Thread André
Hi Leon,

I'd recommend against putting transfer encoding specifics into your 
business model.

There are multiple ways of creating entities which should enable you to 
reuse your current model after a bit of conversion.

BTW: Chunking support is still available in the entity model as well. It 
was only removed from the routing DSL.

HTH
André

On Tuesday, August 25, 2015 at 10:51:14 AM UTC+2, Leon Ma wrote:

 Hi, André

 Thanks for the quick response.

 Actually I'm trying to do some prototyping to see how hard to migrate my 
 spray application into akka-http.

 Here're my case:

 I have a facade Actor binding with Spray Http:

 IO(Http) ! Http.Bind(facadeActorRef, interface, port, settings = 
 Option(settings))

 Within that facade actor, I will dispatch HttpRequest to some other biz 
 Actors(like by uri), and some of the biz actors might return chunked 
 response. 

 I'm not familiar with akka-stream, but I guess I should provide some 
 certain Flow to do the dispatching logic, right? 

 And can I reuse my biz actors as much as possible like adapting them into 
 some akka-stream's artifact (Source?)



 Really appreciate your help!

 Thanks
 Leon




 在 2015年8月25日星期二 UTC-7上午12:49:00,André写道:

 Hi Leon,

 please see the discussion re. chunking here 
 https://github.com/akka/akka/pull/18144.

 What's your use case?

 Cheers,
 André

 On Tuesday, August 25, 2015 at 9:21:46 AM UTC+2, Leon Ma wrote:

 Hi,

 I have some general questions about akka-http:

 1. Is there any concrete samples that illustrate how to return chunked 
 response with akka-http?
 2. Does Route/Directives (high-level api) supports chunked response?


 Thanks
 Leon





-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: akka-http non standard return codes.

2015-08-20 Thread André
Hi Tomasz,

I think akka.http.ParserSettings.withCustomStatusCodes is what you're 
looking for. Its spec is here 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala#L60-L69
.

HTH
André

On Thursday, August 20, 2015 at 11:10:55 AM UTC+2, Tomasz Kogut wrote:

 Hello,

 this is my first post here so let me start with a big Hello to everyone 
 in this fantastic community :)

 As for the question I have a server to which I send request using 
 akka-http. The problem this is a Microsoft IIS that is using rare response 
 code:
   
 HTTP/1.1 440 ..Content-Length: 48..Content-Type: application/json; 
 charset=utf-8..Server: Microsoft-HTTPAPI/2.0..Date: Thu, 20 Aug 2015 
 09:01:11 GMT..Connection: close{..  Message: Ticket expired. Or 
 invalid...}

 this causes akka to throw exception:
 akka.http.scaladsl.model.IllegalResponseException: Illegal response status 
 code

 and of course fails the Future so I don't really know what was the cause 
 of the failure. Is there a way to somehow overcome this limitation?


 --
 BR,
 Tomasz


-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: REST service with Akka and Java

2015-08-05 Thread André
This 
http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/java/http/should
 
get you started. The High-level Server-Side API 
http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0/java/http/routing-dsl/index.html
 
section covers the RESTy stuff.

Cheers
André

On Wednesday, August 5, 2015 at 2:36:19 PM UTC+2, akk...@gmail.com wrote:

 How can I create a REST service with Akka and Java?

 I use Akka version 2.3.19

 I found a huge amount of articles about this topic, some say to use 
 Play-mini, Play, Spray, Camel or Akka-HTTP to build REST services but some 
 of them are outdated, some are working only with Scala, ...

 I'm pretty confused at the moment.

 I would really appreciate if somebody could send me in the right direction.





-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Re: Server attacked. What could have been done?

2015-07-20 Thread André
I think the problem here is that we currently absolutize all requests (
code 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala#L71-L78
).

This will always fail with HTTP/1.0 request as they are always relative and 
don't carry a host header.

I think the requestPreparation Flow in HttpServerBluePrint needs its own 
shortcut that sends 400 responses on exceptions.

On Monday, July 20, 2015 at 3:18:29 AM UTC+2, Ernesto Menéndez wrote:

 Hi √,

 Just for the sake of having a regression test.  I can set up another 
 akka-http app in DigitalOcean designed to log/debug this kind of attack.

 How can I make a service that logs the HTTP request in a useful way?  
 Would the logRequest directive be enough?

 On Sunday, July 19, 2015 at 1:33:24 PM UTC-6, √ wrote:

 Do you have a copy of the actual HTTP request that we could use as a 
 regression test?

 On Sun, Jul 19, 2015 at 8:26 PM, Ernesto Menéndez pya...@gmail.com 
 wrote:

 I received the same request several times when I was hosting my service 
 at DigitalOcean using akka-http RC4. I had to restart the service each time.

 Now that I moved my service to another provider and updated to akka-http 
 1.0, I still haven't got this kind of request or maybe I just haven't 
 noticed as It has been working fine for a couple of hours.  I'll let you 
 know if I see the problem again.



 On Sunday, July 19, 2015 at 9:53:47 AM UTC-6, Nicolau Werneck wrote:

 I am working on this pet project of mine, and I had an HTTP service 
 built with akka-http on-line. The other day I found out it was 
 unavailable, 
 and when I checked in the logs it appears I was a victim of this attack:

 http://www.skepticism.us/2015/05/13/

 I lost the error message, but it was pretty clear that the described 
 request dropped my server, and the problem was the absence of the `Host` 
 header.

 Now, isn't this something akka-http, or any HTTP server or framework, 
 should be robust to? Is there anything I should or could have done as a 
 user to prevent this problem, or should I be filing a bug report? Also, 
 what is a proper way to keep the service running? I was just calling sbt 
 from the command line, really experimental, I know there are better ways 
 out there but I don't know where to start.

 Thanks,
 ++nic

  -- 
  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 akka-user+...@googlegroups.com.
 To post to this group, send email to akka...@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Cheers,
 √
  


-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka http load balancer

2015-05-28 Thread André
Source (and edit button) are here 
https://github.com/akka/akka/blob/release-2.3-dev/akka-docs-dev/rst/scala/http/client-side/request-level.rst.
 
;)

On Thursday, May 28, 2015 at 8:09:27 AM UTC+2, zergood wrote:

 Mistake in docs 
 http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC3/scala/http/client-side/request-level.html
  
 http://www.google.com/url?q=http%3A%2F%2Fdoc.akka.io%2Fdocs%2Fakka-stream-and-http-experimental%2F1.0-RC3%2Fscala%2Fhttp%2Fclient-side%2Frequest-level.htmlsa=Dsntz=1usg=AFQjCNFk7u2ednXynJOI5ubpUSi7sKawQA.
  Http.superPool(...) 
 need to be Http().superPool(...) and the same for Http.singleRequest.
  
 среда, 27 мая 2015 г., 15:01:34 UTC+3 пользователь drewhk написал:

 Hi,

 Instead of Http.request, you should use the Flow returned by 
 Http.superPool() (see 
 http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC3/scala/http/client-side/request-level.html
  
 http://www.google.com/url?q=http%3A%2F%2Fdoc.akka.io%2Fdocs%2Fakka-stream-and-http-experimental%2F1.0-RC3%2Fscala%2Fhttp%2Fclient-side%2Frequest-level.htmlsa=Dsntz=1usg=AFQjCNFk7u2ednXynJOI5ubpUSi7sKawQA).
  
 That flattens out the Futures and you get responses instead. That also 
 makes Balance actually aware of response times.

 OTOH I don't think performance wise akka-http is currently up to the task 
 of being a balancer. 

 -Endre

 On Wed, May 27, 2015 at 1:21 PM, zergood zergoo...@gmail.com wrote:

 Hello! 

 I have a task to develop a http balance loader for my 2 servers. Here is 
 my qucik and very dirty implementation 
 https://gist.github.com/zergood/e705cd6ce4cfec47c0a5. The main problem 
 with it is performance, this solution is slower than my single server. 
 What is the reason of performance degradation? Could you give me any 
 advices how to make http load balancer with akka-http? I am using 
 scala-2.11 and akka-http 1.0-RC3.  

 -- 
  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 akka-user+...@googlegroups.com.
 To post to this group, send email to akka...@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka http load balancer

2015-05-28 Thread André
A quick search revealed some more places that needed fixing. PR submitted 
https://github.com/akka/akka/pull/17594.

On Thursday, May 28, 2015 at 9:22:35 AM UTC+2, André wrote:

 Source (and edit button) are here 
 https://github.com/akka/akka/blob/release-2.3-dev/akka-docs-dev/rst/scala/http/client-side/request-level.rst.
  
 ;)

 On Thursday, May 28, 2015 at 8:09:27 AM UTC+2, zergood wrote:

 Mistake in docs 
 http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC3/scala/http/client-side/request-level.html
  
 http://www.google.com/url?q=http%3A%2F%2Fdoc.akka.io%2Fdocs%2Fakka-stream-and-http-experimental%2F1.0-RC3%2Fscala%2Fhttp%2Fclient-side%2Frequest-level.htmlsa=Dsntz=1usg=AFQjCNFk7u2ednXynJOI5ubpUSi7sKawQA.
  Http.superPool(...) 
 need to be Http().superPool(...) and the same for Http.singleRequest.
  
 среда, 27 мая 2015 г., 15:01:34 UTC+3 пользователь drewhk написал:

 Hi,

 Instead of Http.request, you should use the Flow returned by 
 Http.superPool() (see 
 http://doc.akka.io/docs/akka-stream-and-http-experimental/1.0-RC3/scala/http/client-side/request-level.html
  
 http://www.google.com/url?q=http%3A%2F%2Fdoc.akka.io%2Fdocs%2Fakka-stream-and-http-experimental%2F1.0-RC3%2Fscala%2Fhttp%2Fclient-side%2Frequest-level.htmlsa=Dsntz=1usg=AFQjCNFk7u2ednXynJOI5ubpUSi7sKawQA).
  
 That flattens out the Futures and you get responses instead. That also 
 makes Balance actually aware of response times.

 OTOH I don't think performance wise akka-http is currently up to the 
 task of being a balancer. 

 -Endre

 On Wed, May 27, 2015 at 1:21 PM, zergood zergoo...@gmail.com wrote:

 Hello! 

 I have a task to develop a http balance loader for my 2 servers. Here 
 is my qucik and very dirty implementation 
 https://gist.github.com/zergood/e705cd6ce4cfec47c0a5. The main problem 
 with it is performance, this solution is slower than my single server. 
 What is the reason of performance degradation? Could you give me any 
 advices how to make http load balancer with akka-http? I am using 
 scala-2.11 and akka-http 1.0-RC3.  

 -- 
  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 akka-user+...@googlegroups.com.
 To post to this group, send email to akka...@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: 500 ISE for Client Side Error Bug Report

2015-04-16 Thread André
From https://tools.ietf.org/html/rfc7231#section-4.3.1:

 A payload within a GET request message has no defined semantics;
 sending a payload body on a GET request might cause some existing
 implementations to reject the request.

(Some for HEAD/DELETE/CONNECT)

Perhaps we should relax this requirement to just a warning or make it 
configurable. There seems to be just one other place 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/main/scala/akka/http/engine/rendering/HttpRequestRendererFactory.scala#L103
 
where isEntityAccepted is checked.

On Wednesday, April 15, 2015 at 10:37:57 PM UTC+2, Jim Hazen wrote:

 I was originally thinking that this would be inconvenient for ES clients. 
  I could work around that.  However for anyone attempting to build a 
 transparent proxy in front of ES (where they can't control client calls), 
 this would be an impossible to fix solution if a GET with body was 
 forbidden.


-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: 500 ISE for Client Side Error Bug Report

2015-04-15 Thread André
Hi Kevin,

see 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/main/scala/akka/http/model/HttpMessage.scala#L133

Cheers,
André

On Wednesday, April 15, 2015 at 4:51:33 AM UTC+2, Kevin Meredith wrote:

 There's a Github issue, titled, 500 ISE for Client Side Error -  
 https://github.com/akka/akka/issues/17187.

 For the below error, I grepped for 

 cc2 [ERROR] [04/13/2015 16:01:07.698] 
 [cloud-controller-akka.actor.default-dispatcher-27] 
 [ActorSystem(cloud-controller)] Internal server error, sending 500 response
 cc2 java.lang.IllegalArgumentException: requirement failed: Requests with 
 this method must have an empty entity
 cc2 at scala.Predef$.require(Predef.scala:219)

 $ cd akka 
 $ grep -r method must have an empty entity * | grep -vi test | grep -vi spec
 $

 Where does this code exist? 

 Thanks



-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Akka Http Client - User-Agent header

2015-01-21 Thread André
The RequestBuilding trait is currently only used in tests.

you can use the methods on HttpMessage with RawHeaders instead:

HttpRequest(GET, /some/address.json)
  .withHeaders(
RawHeader(X-Forwarded-For, ...),
RawHeader(SOAPAction, ...),
...)

On Wednesday, January 21, 2015 at 12:51:24 PM UTC+1, Grzegorz Wilkowicz 
wrote:

 Hi,

 What about other custom headers: X-Forwarded-For, SOAPAction, etc? How can 
 I add them to the request?

 W dniu czwartek, 8 stycznia 2015 09:26:11 UTC+1 użytkownik André napisał:

 Hi Marcin,

 the user agent string is a config property and configured here 
 https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/main/resources/reference.conf#L69-L73
 .

 Cheers
 André

 On Wednesday, January 7, 2015 9:14:23 PM UTC+1, Marcin Gosk wrote:

 Hey guys, is it possible to set custom header (User-Agent) for akka 
 streams


  val connection = Http().outgoingConnection(someServer, 443)
 val request:HttpRequest = RequestBuilding.Get(s/some/address.json)
 //I want to add header here

 //request.addHeader(HttpHeader(User-Agent,Mozilla/4.0 (compatible; 
 MSIE 6.0; Windows NT 5.0)))
 Source.single(request).via(connection.flow).runWith(Sink.head).flatMap 
 { response =
   response.status match {
 case status if status.isSuccess =
   val ticker = Unmarshal(response.entity).to[Ticker]
   println(ticker)
   ticker
 case status =
   println(s$status error:${response.toString})
   Future.failed(new IOException(sToken request failed with status 
 ${response.status} and error ${response.entity}))
   }
 }



-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka-http-experimental: Using the spray DSL: how to complete a route with a Source[ByteString]?

2015-01-20 Thread André
Hi Allan,

have you tried the completeWith 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http/src/main/scala/akka/http/server/directives/MarshallingDirectives.scala#L39-L49
 
directive? Look here 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-tests/src/test/scala/akka/http/server/directives/MarshallingDirectivesSpec.scala#L103-L117for
 
examples.

Cheers
André

On Tuesday, January 20, 2015 at 2:14:49 PM UTC+1, Allan Brighton wrote:

 Hi Roland,

 I wasn't sure how to use the new streaming APIs from the spray DSL, so I 
 used the akka-http core API instead:

   implicit val materializer = FlowMaterializer()

   val binding = Http().bind(interface = settings.interface, port = 
 settings.port)
   binding.connections.foreach { c ⇒
 logger.info(sAccepted new connection from ${c.remoteAddress})
 c.handleWithAsyncHandler {
   case HttpRequest(GET, uri, _, _, _)   ⇒ httpGet(uri)
   case HttpRequest(POST, uri, _, entity, _) ⇒ httpPost(uri, entity)
   case HttpRequest(HEAD, uri, _, _, _)  ⇒ httpHead(uri)
   case HttpRequest(DELETE, uri, _, _, _)⇒ httpDelete(uri)
   case _: HttpRequest   ⇒ Future.successful(
 HttpResponse(StatusCodes.NotFound, entity = Unknown resource!))
 }
   }

 Is use of the spray DSL still encouraged or is it deprecated in favour of 
 the above usage?

 Thanks,
 Allan

 On Tuesday, January 20, 2015 at 1:10:56 PM UTC+1, rkuhn wrote:

 Hi Allan,

 there should in principle be a marshaller that wraps your Source into an 
 Entity, what is the exact error you are seeing?

 Regards,

 Roland

 7 jan 2015 kl. 14:00 skrev Allan Brighton alla...@gmail.com:

 Hi,

 I know how to do this now using the new akka-http core API, but how would 
 it work using the spray-like DSL?
 How can I complete an http get using a Future[Source[ByteString]]?

 import akka.http.model._
 import akka.http.server._
 ...
   def route: Route =
 path(get) {
   get {
 parameters('path, 'id ?) { (path, id) =
   respondWithMediaType(`application/octet-stream`) {
 complete {
   val f: Future[Source[ByteString]] = ???
   f.onComplete {
 case Success(source) = ...
 case Failure(ex) = ...
   }
 }
   }
 }
   }
 }

 I would also be interested in an example going the other way: 
 implementing an http post that receives data from a stream.

 Thanks,
 Allan



 -- 
  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 akka-user+...@googlegroups.com.
 To post to this group, send email to akka...@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.




 *Dr. Roland Kuhn*
 *Akka Tech Lead*
 Typesafe http://typesafe.com/ – Reactive apps on the JVM.
 twitter: @rolandkuhn
 http://twitter.com/#!/rolandkuhn
  


-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Akka Http Client - User-Agent header

2015-01-08 Thread André
Hi Marcin,

the user agent string is a config property and configured here 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/main/resources/reference.conf#L69-L73
.

Cheers
André

On Wednesday, January 7, 2015 9:14:23 PM UTC+1, Marcin Gosk wrote:

 Hey guys, is it possible to set custom header (User-Agent) for akka 
 streams


  val connection = Http().outgoingConnection(someServer, 443)
 val request:HttpRequest = RequestBuilding.Get(s/some/address.json)
 //I want to add header here

 //request.addHeader(HttpHeader(User-Agent,Mozilla/4.0 (compatible; 
 MSIE 6.0; Windows NT 5.0)))
 Source.single(request).via(connection.flow).runWith(Sink.head).flatMap { 
 response =
   response.status match {
 case status if status.isSuccess =
   val ticker = Unmarshal(response.entity).to[Ticker]
   println(ticker)
   ticker
 case status =
   println(s$status error:${response.toString})
   Future.failed(new IOException(sToken request failed with status 
 ${response.status} and error ${response.entity}))
   }
 }



-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] akka-http / routing DSL: How to set response content type?

2014-12-12 Thread André
Hi Jo,

as Björn and Mathias exlained there's no need to set the Content-Type 
explicitly. Just import ScalaXmlSupport and complete with a NodeSeq (example 
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-tests/src/test/scala/akka/http/server/TestServer.scala)
 
or alternatively implicitly define a string marshaller for text/html and 
complete 
with a String.

What exactly did you try to trigger this warning?

On Thursday, December 11, 2014 2:01:49 PM UTC+1, Jo Kade wrote:

 Hi Björn,

 thanks for the reply; however, although this solution compiles, I get a 
 runtime warning:

 Explicitly set HTTP header 'Content-Type: text/html' is ignored, explicit 
 `Content-Type` header is not allowed.
 Set `HttpResponse.entity.contentType` instead.

 -- Johannes

 On Thursday, December 11, 2014 11:45:45 AM UTC+1, Björn Antonsson wrote:

 Hi Johannes,

 It seems like there is a mismatch here. The only way that I can find is 
 to use the Java API like this


 respondWithHeaders(akka.http.model.japi.headers.ContentType.create(ContentType(`text/html`)))

 I've opened a ticket here https://github.com/akka/akka/issues/16523

 B/

 On 10 December 2014 at 15:25:21, Jo Kade (jks...@karchedon.de) wrote:

 What is the intended way to set the response content type from within a 
 route?
 In spray there is a respondWithMediaType() directive, but akka-http has 
 not (yet?).
 I cannot use respondeWithHeader(`Content-Type`()) since it has a 
 package-private constructor,
 and using RawHeader(Content-Type,text/html) results in an error. 
 Thanks,

 Best regards,

 Johannes

 --
  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 akka-user+...@googlegroups.com.
 To post to this group, send email to akka...@googlegroups.com.
 Visit this group at http://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.


 -- 
 Björn Antonsson
 Typesafe http://typesafe.com/ – Reactive Apps on the JVM
 twitter: @bantonsson http://twitter.com/#!/bantonsson



-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka remote - one sender's messages missing

2014-10-28 Thread Marc-André Laverdière
Hello everybody!

I am a n00b to Akka. I am trying to add some instrumentation code to an 
application. I use Soot for doing the code transformation, and Akka for the 
communications.

I have to instrument both a client and a server that communicate with each 
other. When running tests, I found that only the server's messages reach 
the actor. Note that client and server run in separate VMs.

Here is my helper and actor code
/**
 * Functions for using the actor
 */
object InstrumentationServer {

  /**
   * Akka actor address
   */
  private lazy val akkaAddress = AddressFromURIString(
akka.tcp://instrumentationServerSystem@localhost:2552)
  /**
   * The Akka actor system
   */
  private lazy val system = ActorSystem(instrumentationServerSystem)

  /**
   * The actor. We don't create many references to it, which means that none
   * will work after a call to `shutdown`
   */
  val instrumentationServerActor = system.actorOf(Props[
InstrumentationServer].
withDeploy(Deploy(scope = RemoteScope(akkaAddress

  /**
   * Shutdown the actor system.
   * There is NO guarantee that the processing are over by the actors, as 
they are fully asynchronous by design.
   *
   */
  def shutdown() = {
system.stop(instrumentationServerActor)
system.shutdown()
system.awaitTermination(Duration(5, TimeUnit.SECONDS))
  }

  /**
   * File where the detected event paths are stored
   */
  val outputPath = ws-paths.txt

  val actorRunningTmpFile = darwini-instrument-actor-running

  /**
   * The above, as a Path object
   */
  private val target = Paths.get(outputPath).toAbsolutePath

  /**
   * Writes the events to the file. This has been moved to the companion 
object
   * because Akka would crash with a java.lang.NoClassDefFoundError if the 
actor was referencting `outputPath`. This is not
   * an ideal design, but its internal this file, so we can manage.
   * @param events the sequence of events
   */
  private[InstrumentationServer] def writeEventsToFile(events: Seq[Message
]): Unit = {
val eventsPlain = events.map(ev = (ev.clazz, ev.method, ev.line))
val formatted = eventsPlain.mkString(-)
//Yes, this is wasteful compared to keeping a writer in memory, but the 
number of writes
//should be small anyway, so that's not a big deal
Files.write(target, Seq(formatted).asJava, Codec.UTF8.charSet,
  StandardOpenOption.CREATE, StandardOpenOption.APPEND, 
StandardOpenOption.WRITE, StandardOpenOption.SYNC)
  }

}

import InstrumentationServer._


/**
 * This actor receives messages that the instrumented code will generate.
 * It essentially stores the messages according to order of arrival and 
writes them
 * to file `InstrumentationServer.outputPath` at the end of each sequence.
 */
class InstrumentationServer extends Actor {

  val tmpFile = Files.createTempFile(actorRunningTmpFile, .tmp)

  override def aroundReceive(receive: Actor.Receive, msg: Any): Unit = {
Files.write(tmpFile, Seq(sMessage received: $msg).asJava,
  Codec.UTF8.charSet, StandardOpenOption.WRITE, StandardOpenOption.
APPEND, StandardOpenOption.SYNC)
super.aroundReceive(receive, msg)
  }

  //Ideally, I should use an Iteratee, instead
  private val events = ArrayBuffer[Message]()

  //Currently, we assume ordered input order
  override def receive: Receive = {
case m: StartInteractionMessage = events.clear(); events += m
case m: ProcessingModuleExecuteMessage = events += m
case m: StopInteractionMessage = events += m; writeEventsToFile(events)
  }
}

In the code I instrument, I essentially inject 
InstrumentationServer,instrumentationServerActor.tell(msg, null).

Note that the code in aroundReceive is just for debugging.

Now, what am I doing wrong? I would like the actor to be created 
automagically, receive messages from both client and server, dump to file 
and be done with it. I'm sure there is a way to do that :)


-- 
  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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.