Karate Server - malformed header name: access-control-allow-credentials
See original GitHub issueI am trying to run a karate server, and trying to bypass cors by setting the appropriate headers…
Problem is when I set access-control-allow-credentials
, the server throws an error when serving the endpoint.
The below is my mock server code.
Feature: mock auth server
Background:
# auth
Scenario: pathMatches('/api/v1/auth') && methodIs('options')
* def responseHeaders =
"""
{
"access-control-allow-credentials:" : "true",
"access-control-allow-headers" : "*",
"access-control-allow-origin" : "*",
"access-control-allow-methods" : "GET, HEAD, POST, PUT, DELETE, PATCH"
}
"""
* def responseStatus = 200
Scenario: pathMatches('/api/v1/auth') && methodIs('post')
* def username = request.username
* def password = request.password
the command I use to run this server
./karate-1.1.0.RC5/karate -p 8099 -s -m ./mock-auth-server.feature
the error I get is
10:46:05.919 [armeria-common-worker-nio-2-2] WARN c.l.a.server.HttpResponseSubscriber - [id: 0x9375113a, L:/0:0:0:0:0:0:0:1:8099 - R:/0:0:0:0:0:0:0:1:63917] Unexpected exception from a service or a response publisher: com.intuit.karate.http.HttpServerHandler@5d99a6ac
java.lang.IllegalArgumentException: malformed header name: access-control-allow-credentials:
at com.linecorp.armeria.common.HttpHeaderNames.validate(HttpHeaderNames.java:698)
at com.linecorp.armeria.common.HttpHeaderNames.of(HttpHeaderNames.java:641)
at com.linecorp.armeria.common.HttpHeadersBase.normalizeName(HttpHeadersBase.java:117)
at com.linecorp.armeria.common.HttpHeadersBase.normalizeName(HttpHeadersBase.java:57)
at com.linecorp.armeria.common.StringMultimap.add(StringMultimap.java:506)
at com.linecorp.armeria.common.StringMultimapBuilder.add(StringMultimapBuilder.java:369)
at com.linecorp.armeria.common.DefaultResponseHeadersBuilder.add(DefaultResponseHeadersBuilder.java:21)
at com.intuit.karate.http.HttpServerHandler.lambda$toResponse$1(HttpServerHandler.java:97)
at java.base/java.util.HashMap.forEach(HashMap.java:1336)
at com.intuit.karate.http.HttpServerHandler.toResponse(HttpServerHandler.java:97)
at com.intuit.karate.http.HttpServerHandler.lambda$serve$0(HttpServerHandler.java:60)
at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
at com.intuit.karate.http.HttpServerHandler.serve(HttpServerHandler.java:57)
at com.linecorp.armeria.server.HttpServerHandler.handleRequest(HttpServerHandler.java:387)
at com.linecorp.armeria.server.HttpServerHandler.channelRead(HttpServerHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at com.linecorp.armeria.server.Http2RequestDecoder.onHeadersRead(Http2RequestDecoder.java:162)
at com.linecorp.armeria.server.Http2RequestDecoder.onHeadersRead(Http2RequestDecoder.java:182)
at io.netty.handler.codec.http2.Http2FrameListenerDecorator.onHeadersRead(Http2FrameListenerDecorator.java:48)
at io.netty.handler.codec.http2.Http2EmptyDataFrameListener.onHeadersRead(Http2EmptyDataFrameListener.java:63)
at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder$FrameReadListener.onHeadersRead(DefaultHttp2ConnectionDecoder.java:420)
at io.netty.handler.codec.http2.DefaultHttp2FrameReader$1.processFragment(DefaultHttp2FrameReader.java:457)
at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readHeadersFrame(DefaultHttp2FrameReader.java:464)
at io.netty.handler.codec.http2.DefaultHttp2FrameReader.processPayloadState(DefaultHttp2FrameReader.java:254)
at io.netty.handler.codec.http2.DefaultHttp2FrameReader.readFrame(DefaultHttp2FrameReader.java:160)
at io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder.decodeFrame(DefaultHttp2ConnectionDecoder.java:181)
at io.netty.handler.codec.http2.DecoratingHttp2ConnectionDecoder.decodeFrame(DecoratingHttp2ConnectionDecoder.java:63)
at io.netty.handler.codec.http2.Http2ConnectionHandler$FrameDecoder.decode(Http2ConnectionHandler.java:378)
at io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.logging.LoggingHandler.channelRead(LoggingHandler.java:271)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1504)
at io.netty.handler.ssl.SslHandler.decodeNonJdkCompatible(SslHandler.java:1265)
at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1302)
at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:508)
at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:447)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.flush.FlushConsolidationHandler.channelRead(FlushConsolidationHandler.java:152)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
PS. I am NOT using configure corsEnabled = true
because it doesnt seem to set the allow-credentials
header
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Writing integration tests for CORS headers (with Karate)
In this article I will show how to create tests for the correct headers (using Karate, but it should be applicable to any...
Read more >Post request giving 400 bad request error in Karate with Json ...
1 Answer 1 ... It is very clear that the server has thrown this error, and it looks like Karate has sent JSON...
Read more >Unable to set Access-Control-Allow-Credentials Header on ...
When deployed via Vercel, the tracker is unable to send requests to the Ackee API since the Access-Control-Allow-Credentials header is missing.
Read more >If-Match - HTTP - MDN Web Docs - Mozilla
The If-Match HTTP request header makes a request conditional. A server will only return requested resources for GET and HEAD methods, ...
Read more >cookie run thailand - CSDN
Discord chat server · VueJS Indonesia - Telegram Group [Indonesian] ... Uploader shows file names, sizes and total size of files added.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
reopening and tagging as
help wanted
@SatheeshJM no worries !