prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Incorrect response content-type header from cloudwatch logs
  When using the .NET AWSSDK connected to localstack and querying cloudwatch logs e.g. 
   var logClient = new AmazonCloudWatchLogsClient(new AmazonCloudWatchLogsConfig()
              {
                  ServiceURL = "http://localhost:4586",
                  UseHttp = true,
                  AuthenticationRegion = "eu-central-1",
              });
              var logGroupName = @"/aws/lambda/f1";
              var events = logClient.FilterLogEventsAsync(new FilterLogEventsRequest()
              {
                  LogGroupName = logGroupName,
              }).GetAwaiter().GetResult();
  
  The response is returned from the server but cannot be parsed by the SDK client code because the response's content-type header is text/html when it should be application/x-amz-json-1.1.  This confirmed using Fiddler traces comparing the response from localstack to the response from AWS in the cloud. Can this be fixed easily?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `localstack/services/logs/logs_listener.py`
  Content:
  ```
  1 import re
  2 from requests.models import Request
  3 from localstack.utils.common import to_str
  4 from localstack.services.generic_proxy import ProxyListener
  5 
  6 
  7 class ProxyListenerCloudWatchLogs(ProxyListener):
  8 
  9     def forward_request(self, method, path, data, headers):
  10         if method == 'POST' and path == '/':
  11             if 'nextToken' in to_str(data or ''):
  12                 data = self._fix_next_token_request(data)
  13                 headers['content-length'] = str(len(data))
  14                 return Request(data=data, headers=headers, method=method)
  15 
  16         return True
  17 
  18     def return_response(self, method, path, data, headers, response):
  19         if 'nextToken' in to_str(response.content or ''):
  20             self._fix_next_token_response(response)
  21             response.headers['content-length'] = str(len(response._content))
  22 
  23     def _fix_next_token_request(self, data):
  24         # Fix for https://github.com/localstack/localstack/issues/1527
  25         pattern = r'"nextToken":\s*"([0-9]+)"'
  26         replacement = r'"nextToken": \1'
  27         return re.sub(pattern, replacement, to_str(data))
  28 
  29     def _fix_next_token_response(self, response):
  30         # Fix for https://github.com/localstack/localstack/issues/1527
  31         pattern = r'"nextToken":\s*([0-9]+)'
  32         replacement = r'"nextToken": "\1"'
  33         response._content = re.sub(pattern, replacement, to_str(response.content))
  34 
  35 
  36 # instantiate listener
  37 UPDATE_LOGS = ProxyListenerCloudWatchLogs()
  38
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/localstack/services/logs/logs_listener.py b/localstack/services/logs/logs_listener.py
  --- a/localstack/services/logs/logs_listener.py
  +++ b/localstack/services/logs/logs_listener.py
  @@ -1,11 +1,11 @@
   import re
   from requests.models import Request
   from localstack.utils.common import to_str
  +from localstack.constants import APPLICATION_AMZ_JSON_1_1
   from localstack.services.generic_proxy import ProxyListener
   
   
   class ProxyListenerCloudWatchLogs(ProxyListener):
  -
       def forward_request(self, method, path, data, headers):
           if method == 'POST' and path == '/':
               if 'nextToken' in to_str(data or ''):
  @@ -16,17 +16,22 @@
           return True
   
       def return_response(self, method, path, data, headers, response):
  +        # Fix Incorrect response content-type header from cloudwatch logs #1343
  +        response.headers['content-type'] = APPLICATION_AMZ_JSON_1_1
  +
           if 'nextToken' in to_str(response.content or ''):
               self._fix_next_token_response(response)
               response.headers['content-length'] = str(len(response._content))
   
  -    def _fix_next_token_request(self, data):
  +    @staticmethod
  +    def _fix_next_token_request(data):
           # Fix for https://github.com/localstack/localstack/issues/1527
           pattern = r'"nextToken":\s*"([0-9]+)"'
           replacement = r'"nextToken": \1'
           return re.sub(pattern, replacement, to_str(data))
   
  -    def _fix_next_token_response(self, response):
  +    @staticmethod
  +    def _fix_next_token_response(response):
           # Fix for https://github.com/localstack/localstack/issues/1527
           pattern = r'"nextToken":\s*([0-9]+)'
           replacement = r'"nextToken": "\1"'
  
verification_info: {"golden_diff": "diff --git a/localstack/services/logs/logs_listener.py b/localstack/services/logs/logs_listener.py\n--- a/localstack/services/logs/logs_listener.py\n+++ b/localstack/services/logs/logs_listener.py\n@@ -1,11 +1,11 @@\n import re\n from requests.models import Request\n from localstack.utils.common import to_str\n+from localstack.constants import APPLICATION_AMZ_JSON_1_1\n from localstack.services.generic_proxy import ProxyListener\n \n \n class ProxyListenerCloudWatchLogs(ProxyListener):\n-\n     def forward_request(self, method, path, data, headers):\n         if method == 'POST' and path == '/':\n             if 'nextToken' in to_str(data or ''):\n@@ -16,17 +16,22 @@\n         return True\n \n     def return_response(self, method, path, data, headers, response):\n+        # Fix Incorrect response content-type header from cloudwatch logs #1343\n+        response.headers['content-type'] = APPLICATION_AMZ_JSON_1_1\n+\n         if 'nextToken' in to_str(response.content or ''):\n             self._fix_next_token_response(response)\n             response.headers['content-length'] = str(len(response._content))\n \n-    def _fix_next_token_request(self, data):\n+    @staticmethod\n+    def _fix_next_token_request(data):\n         # Fix for https://github.com/localstack/localstack/issues/1527\n         pattern = r'\"nextToken\":\\s*\"([0-9]+)\"'\n         replacement = r'\"nextToken\": \\1'\n         return re.sub(pattern, replacement, to_str(data))\n \n-    def _fix_next_token_response(self, response):\n+    @staticmethod\n+    def _fix_next_token_response(response):\n         # Fix for https://github.com/localstack/localstack/issues/1527\n         pattern = r'\"nextToken\":\\s*([0-9]+)'\n         replacement = r'\"nextToken\": \"\\1\"'\n", "issue": "Incorrect response content-type header from cloudwatch logs\nWhen using the .NET AWSSDK connected to localstack and querying cloudwatch logs e.g. \r\n var logClient = new AmazonCloudWatchLogsClient(new AmazonCloudWatchLogsConfig()\r\n            {\r\n                ServiceURL = \"http://localhost:4586\",\r\n                UseHttp = true,\r\n                AuthenticationRegion = \"eu-central-1\",\r\n            });\r\n            var logGroupName = @\"/aws/lambda/f1\";\r\n            var events = logClient.FilterLogEventsAsync(new FilterLogEventsRequest()\r\n            {\r\n                LogGroupName = logGroupName,\r\n            }).GetAwaiter().GetResult();\r\n\r\nThe response is returned from the server but cannot be parsed by the SDK client code because the response's content-type header is text/html when it should be application/x-amz-json-1.1.  This confirmed using Fiddler traces comparing the response from localstack to the response from AWS in the cloud. Can this be fixed easily?\n", "before_files": [{"content": "import re\nfrom requests.models import Request\nfrom localstack.utils.common import to_str\nfrom localstack.services.generic_proxy import ProxyListener\n\n\nclass ProxyListenerCloudWatchLogs(ProxyListener):\n\n    def forward_request(self, method, path, data, headers):\n        if method == 'POST' and path == '/':\n            if 'nextToken' in to_str(data or ''):\n                data = self._fix_next_token_request(data)\n                headers['content-length'] = str(len(data))\n                return Request(data=data, headers=headers, method=method)\n\n        return True\n\n    def return_response(self, method, path, data, headers, response):\n        if 'nextToken' in to_str(response.content or ''):\n            self._fix_next_token_response(response)\n            response.headers['content-length'] = str(len(response._content))\n\n    def _fix_next_token_request(self, data):\n        # Fix for https://github.com/localstack/localstack/issues/1527\n        pattern = r'\"nextToken\":\\s*\"([0-9]+)\"'\n        replacement = r'\"nextToken\": \\1'\n        return re.sub(pattern, replacement, to_str(data))\n\n    def _fix_next_token_response(self, response):\n        # Fix for https://github.com/localstack/localstack/issues/1527\n        pattern = r'\"nextToken\":\\s*([0-9]+)'\n        replacement = r'\"nextToken\": \"\\1\"'\n        response._content = re.sub(pattern, replacement, to_str(response.content))\n\n\n# instantiate listener\nUPDATE_LOGS = ProxyListenerCloudWatchLogs()\n", "path": "localstack/services/logs/logs_listener.py"}], "after_files": [{"content": "import re\nfrom requests.models import Request\nfrom localstack.utils.common import to_str\nfrom localstack.constants import APPLICATION_AMZ_JSON_1_1\nfrom localstack.services.generic_proxy import ProxyListener\n\n\nclass ProxyListenerCloudWatchLogs(ProxyListener):\n    def forward_request(self, method, path, data, headers):\n        if method == 'POST' and path == '/':\n            if 'nextToken' in to_str(data or ''):\n                data = self._fix_next_token_request(data)\n                headers['content-length'] = str(len(data))\n                return Request(data=data, headers=headers, method=method)\n\n        return True\n\n    def return_response(self, method, path, data, headers, response):\n        # Fix Incorrect response content-type header from cloudwatch logs #1343\n        response.headers['content-type'] = APPLICATION_AMZ_JSON_1_1\n\n        if 'nextToken' in to_str(response.content or ''):\n            self._fix_next_token_response(response)\n            response.headers['content-length'] = str(len(response._content))\n\n    @staticmethod\n    def _fix_next_token_request(data):\n        # Fix for https://github.com/localstack/localstack/issues/1527\n        pattern = r'\"nextToken\":\\s*\"([0-9]+)\"'\n        replacement = r'\"nextToken\": \\1'\n        return re.sub(pattern, replacement, to_str(data))\n\n    @staticmethod\n    def _fix_next_token_response(response):\n        # Fix for https://github.com/localstack/localstack/issues/1527\n        pattern = r'\"nextToken\":\\s*([0-9]+)'\n        replacement = r'\"nextToken\": \"\\1\"'\n        response._content = re.sub(pattern, replacement, to_str(response.content))\n\n\n# instantiate listener\nUPDATE_LOGS = ProxyListenerCloudWatchLogs()\n", "path": "localstack/services/logs/logs_listener.py"}]}