Akka http server responds HEAD request as GET#4494
Conversation
|
@SugandhaAgrawal I believe this is Akka HTTP Server setting and not related to client. If we enable this would HEAD request still work in OpenWhisk or would fail. I presume so far they work just that internally executed as GET. However with this change would they stop working if route does not implement HEAD support? |
|
It'd be useful to get some context on the use-cases that trigger this issue. |
|
the context of this issue is actually quite straightforward: We have seen users trying to implement a web action that responds differently on HEAD than on GET. However, given |
|
Got it, that makes sense. I guess @chetanmeh was confused (so was I) because the initial description talks about akka-https client not behaving as expected. @chetanmeh is also right though that this is a breaking change as currently working HEAD requests will now fail. |
|
i wouldn't consider to be a breaking change per se, but rather a bug fix. It was just flatout wrong that when a |
|
@markusthoemmes I have the same thought as Michael's. I would say this is a bug fix. The breaking change in terms that the users need to change the implementation is fine but this is right way to handle the HEAD request. |
|
@markusthoemmes The initial description does mean that akka http client isnt behaving as expected by default. It responds HEAD with a GET and that isnt the right response in my opinion. |
|
@SugandhaAgrawal the point is that it's the akka http server, not the client. I'm indecisive on the bug fix vs. breaking change. I agree though that the amount of breakage is very small and arguably relying on undocumented/wrong behavior. If @chetanmeh doesn't have strong feelings against it I'm fine merging this as-is. Otherwise we should take it to the dev-list. |
|
@markusthoemmes Thanks for the correction, server ;) |
chetanmeh
left a comment
There was a problem hiding this comment.
Given web actions need to distinguish the request it makes sense for this change.
Would be good to have a test to assert this behavior i.e. _ow_method is indeed HEAD post this change
|
@chetanmeh I will include test in the next PR. I will add the output of my manual tests here for supporting the change. |
|
If this fix is not very urgent would it be possible to include the test in this PR itself. I believe you can still enable this flag in your setups via system property |
|
I agree this is a bug - the intended behavior is for the HEAD to reach the function just like OPTIONS. You'll need a system level tests (in |
|
@chetanmeh I'm not sure if existing actions would fail --- at least not all. I suspect that you need actions which have already opted out of the default CORS response. |
|
@SugandhaAgrawal any luck adding a test for this fix? |
|
@rabbah Unfortunately not. I was on vacation and returned today. Will work on it |
|
welcome back! |
There was a problem hiding this comment.
@SugandhaAgrawal, there should be some existing webaction tests that you can use as a template to test this one. Hopefully you can do a unit test for this, can't remember since I haven't looked at those in awhile. Integration test will definitely work though.
Nice find, BTW!
e684e33 to
21b08d1
Compare
f2ba1ca to
321a7d5
Compare
Codecov Report
@@ Coverage Diff @@
## master #4494 +/- ##
==========================================
- Coverage 83.65% 80.06% -3.59%
==========================================
Files 174 174
Lines 8023 8023
Branches 552 552
==========================================
- Hits 6712 6424 -288
- Misses 1311 1599 +288
Continue to review full report at Codecov.
|
321a7d5 to
9e713d3
Compare
| @@ -0,0 +1,9 @@ | |||
| // Licensed to the Apache Software Foundation (ASF) under one or more contributor | |||
| // license agreements; and to You under the Apache License, Version 2.0. | |||
There was a problem hiding this comment.
Please use the long form license. We have to stop using the short form.
There was a problem hiding this comment.
Wasnt aware of the 2 versions of license headers. I have made the update.
There was a problem hiding this comment.
it was a recent change.
thanks for the update!
9e713d3 to
de1678d
Compare
rabbah
left a comment
There was a problem hiding this comment.
modulo the comment about auth.
| val url = s"$host$testRoutePath/$namespace/default/$name" | ||
|
|
||
| assetHelper.withCleaner(wsk.action, name) { (action, _) => | ||
| action.create(name, file, web = Some("true"), annotations = Map("require-whisk-auth" -> true.toJson)) |
There was a problem hiding this comment.
i think you can skip the require-whisk-auth annotation here.
| } | ||
|
|
||
| val unauthorizedResponse = RestAssured.given().config(sslconfig).head(url) | ||
| unauthorizedResponse.statusCode shouldBe 401 |
There was a problem hiding this comment.
and then remove this unless this is important to the test.
de1678d to
4549e0b
Compare
|
@rabbah Please merge this, if everything looks good! |
|
Thanks @SugandhaAgrawal 👍 |

Akka http client by default treats any http HEAD request as GET unless the configuration sets it otherwise. There are use cases where user expects HEAD to be responded as HEAD and without a response body unlike GET.
akka/akka-http#2088 mentions that the default is set to treat a HEAD as a GET request by the Akka client.
Description
Update the controller configuration to process HEAD and GET requests as they are expected.
Related issue and scope
My changes affect the following components
Types of changes
Checklist: