question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is here assuming all responses are using "Content-Type: application/json"?

See original GitHub issue

https://github.com/awslabs/aws-sam-local/blob/629e6277c88b6a41edcc38f5f7227ad29888b78d/runtime.go#L544

I am hitting an issue that sam-local response contains multiple contradicted “Content-Type” header. Please see the following curl command debugging output. In my API, the only Content-Type defined is text/plain format, but using the sam-local test, its response message contains an extra “Content-Type” header application/json. Could you please confirm is this line injecting the header, if so, can this assumption be removed and honor the response header returned by Lambda functions?

Please see the following out console output.

$> curl -v -H "Accept: text/plain" http://127.0.0.1:3000/resources/greeting
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> GET /resources/greeting HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.54.0
> Accept: text/plain
>
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Type: text/plain
< Date: Mon, 19 Mar 2018 07:21:00 GMT
< Content-Length: 5
<
* Connection #0 to host 127.0.0.1 left intact
Hello

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ronaldwidhacommented, Apr 12, 2018

confirmed.

$ curl -v --header 'Accept:text/html' 'http://localhost:8080/'

yields

...
< HTTP/1.1 200 OK
< Content-Type: application/json
< Content-Type: text/html
< Date: Thu, 12 Apr 2018 13:40:56 GMT
...
0reactions
jfusscommented, May 9, 2018

This should be fixed in our newest release: https://github.com/awslabs/aws-sam-cli/releases/tag/v0.3.0

Please feel free to reopen if the issue persists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content-Type: application/json is forced as response header ...
I use aws-sam-local local start-api for local development. However all the resources have a Content-Type: application/json header set, ...
Read more >
Which JSON content type do I use? - Stack Overflow
The correct MIME media type for JSON is application/json . JSP will use it for sending a response to the client. Share.
Read more >
CFC, returnForm, JSON, and content-type - Raymond Camden
I'm assuming cfajaxproxy actually ran the CFC when creating the proxy. This seems to be an issue with cfajaxproxy only though. I changed...
Read more >
Blogger JSON API: Performance Tips - Google Developers
This document covers some techniques you can use to improve the performance of your application. In some cases, examples from other APIs or ......
Read more >
Best practices for REST API design - Stack Overflow Blog
Accept and respond with JSON. REST APIs should accept JSON for request payload and also send responses to JSON. JSON is the standard...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found