prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Bug: lingva engine / redirects & Key-Errors
  **Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**
  
  Repository: https://github.com/return42/searxng
  Branch: darmarit.org
  Version: 2024.2.3+a6f5d690
  
  **How did you install SearXNG?**
  
  (unmodified fork/brand) from master branch
  
  **What happened?**
  
  With the default config / the "official instance" we have the errors reported below:
  
  https://github.com/searxng/searxng/blob/df1a774003c285866a96b149bf92412037b4932d/searx/settings.yml#L1037-L1041
  
  **How To Reproduce**
  
  ```
  !lingva en-de convenient
  ```
  
  **Technical report**
  
  ```
  Error
    * Error: httpx.ReadTimeout
    * Percentage: 50
    * Parameters: `(None, None, 'lingva.thedaviddelta.com')`
    * File name: `searx/search/processors/online.py:118`
    * Function: `_send_http_request`
    * Code: `response = req(params['url'], **request_args)`
  ```
  
  ```
  Error
    * Error: 1 redirects, maximum: 0
    * Percentage: 50
    * Parameters: `('200', 'OK', 'lingva.thedaviddelta.com')`
    * File name: `searx/search/processors/online.py:127`
    * Function: `_send_http_request`
    * Code: `count_error(`
  ```
  
  ```
  Error
    * Error: KeyError
    * Percentage: 50
    * Parameters: `()`
    * File name: `searx/engines/lingva.py:51`
    * Function: `response`
    * Code: `infobox += f"<b>{translation['type']}</b>"`
  ```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `searx/engines/lingva.py`
  Content:
  ```
  1 # SPDX-License-Identifier: AGPL-3.0-or-later
  2 # lint: pylint
  3 """Lingva (alternative Google Translate frontend)"""
  4 
  5 from json import loads
  6 
  7 about = {
  8     "website": 'https://lingva.ml',
  9     "wikidata_id": None,
  10     "official_api_documentation": 'https://github.com/thedaviddelta/lingva-translate#public-apis',
  11     "use_official_api": True,
  12     "require_api_key": False,
  13     "results": 'JSON',
  14 }
  15 
  16 engine_type = 'online_dictionary'
  17 categories = ['general']
  18 
  19 url = "https://lingva.thedaviddelta.com/"
  20 search_url = "{url}/api/v1/{from_lang}/{to_lang}/{query}"
  21 
  22 
  23 def request(_query, params):
  24     params['url'] = search_url.format(
  25         url=url, from_lang=params['from_lang'][1], to_lang=params['to_lang'][1], query=params['query']
  26     )
  27     return params
  28 
  29 
  30 def response(resp):
  31     results = []
  32 
  33     result = loads(resp.text)
  34     info = result["info"]
  35     from_to_prefix = "%s-%s " % (resp.search_params['from_lang'][1], resp.search_params['to_lang'][1])
  36 
  37     if "typo" in info:
  38         results.append({"suggestion": from_to_prefix + info["typo"]})
  39 
  40     if 'definitions' in info:  # pylint: disable=too-many-nested-blocks
  41         for definition in info['definitions']:
  42             if 'list' in definition:
  43                 for item in definition['list']:
  44                     if 'synonyms' in item:
  45                         for synonym in item['synonyms']:
  46                             results.append({"suggestion": from_to_prefix + synonym})
  47 
  48     infobox = ""
  49 
  50     for translation in info["extraTranslations"]:
  51         infobox += f"<b>{translation['type']}</b>"
  52 
  53         for word in translation["list"]:
  54             infobox += f"<dl><dt>{word['word']}</dt>"
  55 
  56             for meaning in word["meanings"]:
  57                 infobox += f"<dd>{meaning}</dd>"
  58 
  59             infobox += "</dl>"
  60 
  61     results.append(
  62         {
  63             'infobox': result["translation"],
  64             'content': infobox,
  65         }
  66     )
  67 
  68     return results
  69
  ```
  --- 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/searx/engines/lingva.py b/searx/engines/lingva.py
  --- a/searx/engines/lingva.py
  +++ b/searx/engines/lingva.py
  @@ -16,7 +16,7 @@
   engine_type = 'online_dictionary'
   categories = ['general']
   
  -url = "https://lingva.thedaviddelta.com/"
  +url = "https://lingva.thedaviddelta.com"
   search_url = "{url}/api/v1/{from_lang}/{to_lang}/{query}"
   
   
  @@ -48,8 +48,6 @@
       infobox = ""
   
       for translation in info["extraTranslations"]:
  -        infobox += f"<b>{translation['type']}</b>"
  -
           for word in translation["list"]:
               infobox += f"<dl><dt>{word['word']}</dt>"
  
verification_info: {"golden_diff": "diff --git a/searx/engines/lingva.py b/searx/engines/lingva.py\n--- a/searx/engines/lingva.py\n+++ b/searx/engines/lingva.py\n@@ -16,7 +16,7 @@\n engine_type = 'online_dictionary'\n categories = ['general']\n \n-url = \"https://lingva.thedaviddelta.com/\"\n+url = \"https://lingva.thedaviddelta.com\"\n search_url = \"{url}/api/v1/{from_lang}/{to_lang}/{query}\"\n \n \n@@ -48,8 +48,6 @@\n     infobox = \"\"\n \n     for translation in info[\"extraTranslations\"]:\n-        infobox += f\"<b>{translation['type']}</b>\"\n-\n         for word in translation[\"list\"]:\n             infobox += f\"<dl><dt>{word['word']}</dt>\"\n", "issue": "Bug: lingva engine / redirects & Key-Errors\n**Version of SearXNG, commit number if you are using on master branch and stipulate if you forked SearXNG**\r\n\r\nRepository: https://github.com/return42/searxng\r\nBranch: darmarit.org\r\nVersion: 2024.2.3+a6f5d690\r\n\r\n**How did you install SearXNG?**\r\n\r\n(unmodified fork/brand) from master branch\r\n\r\n**What happened?**\r\n\r\nWith the default config / the \"official instance\" we have the errors reported below:\r\n\r\nhttps://github.com/searxng/searxng/blob/df1a774003c285866a96b149bf92412037b4932d/searx/settings.yml#L1037-L1041\r\n\r\n**How To Reproduce**\r\n\r\n```\r\n!lingva en-de convenient\r\n```\r\n\r\n**Technical report**\r\n\r\n```\r\nError\r\n  * Error: httpx.ReadTimeout\r\n  * Percentage: 50\r\n  * Parameters: `(None, None, 'lingva.thedaviddelta.com')`\r\n  * File name: `searx/search/processors/online.py:118`\r\n  * Function: `_send_http_request`\r\n  * Code: `response = req(params['url'], **request_args)`\r\n```\r\n\r\n```\r\nError\r\n  * Error: 1 redirects, maximum: 0\r\n  * Percentage: 50\r\n  * Parameters: `('200', 'OK', 'lingva.thedaviddelta.com')`\r\n  * File name: `searx/search/processors/online.py:127`\r\n  * Function: `_send_http_request`\r\n  * Code: `count_error(`\r\n```\r\n\r\n```\r\nError\r\n  * Error: KeyError\r\n  * Percentage: 50\r\n  * Parameters: `()`\r\n  * File name: `searx/engines/lingva.py:51`\r\n  * Function: `response`\r\n  * Code: `infobox += f\"<b>{translation['type']}</b>\"`\r\n```\n", "before_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n# lint: pylint\n\"\"\"Lingva (alternative Google Translate frontend)\"\"\"\n\nfrom json import loads\n\nabout = {\n    \"website\": 'https://lingva.ml',\n    \"wikidata_id\": None,\n    \"official_api_documentation\": 'https://github.com/thedaviddelta/lingva-translate#public-apis',\n    \"use_official_api\": True,\n    \"require_api_key\": False,\n    \"results\": 'JSON',\n}\n\nengine_type = 'online_dictionary'\ncategories = ['general']\n\nurl = \"https://lingva.thedaviddelta.com/\"\nsearch_url = \"{url}/api/v1/{from_lang}/{to_lang}/{query}\"\n\n\ndef request(_query, params):\n    params['url'] = search_url.format(\n        url=url, from_lang=params['from_lang'][1], to_lang=params['to_lang'][1], query=params['query']\n    )\n    return params\n\n\ndef response(resp):\n    results = []\n\n    result = loads(resp.text)\n    info = result[\"info\"]\n    from_to_prefix = \"%s-%s \" % (resp.search_params['from_lang'][1], resp.search_params['to_lang'][1])\n\n    if \"typo\" in info:\n        results.append({\"suggestion\": from_to_prefix + info[\"typo\"]})\n\n    if 'definitions' in info:  # pylint: disable=too-many-nested-blocks\n        for definition in info['definitions']:\n            if 'list' in definition:\n                for item in definition['list']:\n                    if 'synonyms' in item:\n                        for synonym in item['synonyms']:\n                            results.append({\"suggestion\": from_to_prefix + synonym})\n\n    infobox = \"\"\n\n    for translation in info[\"extraTranslations\"]:\n        infobox += f\"<b>{translation['type']}</b>\"\n\n        for word in translation[\"list\"]:\n            infobox += f\"<dl><dt>{word['word']}</dt>\"\n\n            for meaning in word[\"meanings\"]:\n                infobox += f\"<dd>{meaning}</dd>\"\n\n            infobox += \"</dl>\"\n\n    results.append(\n        {\n            'infobox': result[\"translation\"],\n            'content': infobox,\n        }\n    )\n\n    return results\n", "path": "searx/engines/lingva.py"}], "after_files": [{"content": "# SPDX-License-Identifier: AGPL-3.0-or-later\n# lint: pylint\n\"\"\"Lingva (alternative Google Translate frontend)\"\"\"\n\nfrom json import loads\n\nabout = {\n    \"website\": 'https://lingva.ml',\n    \"wikidata_id\": None,\n    \"official_api_documentation\": 'https://github.com/thedaviddelta/lingva-translate#public-apis',\n    \"use_official_api\": True,\n    \"require_api_key\": False,\n    \"results\": 'JSON',\n}\n\nengine_type = 'online_dictionary'\ncategories = ['general']\n\nurl = \"https://lingva.thedaviddelta.com\"\nsearch_url = \"{url}/api/v1/{from_lang}/{to_lang}/{query}\"\n\n\ndef request(_query, params):\n    params['url'] = search_url.format(\n        url=url, from_lang=params['from_lang'][1], to_lang=params['to_lang'][1], query=params['query']\n    )\n    return params\n\n\ndef response(resp):\n    results = []\n\n    result = loads(resp.text)\n    info = result[\"info\"]\n    from_to_prefix = \"%s-%s \" % (resp.search_params['from_lang'][1], resp.search_params['to_lang'][1])\n\n    if \"typo\" in info:\n        results.append({\"suggestion\": from_to_prefix + info[\"typo\"]})\n\n    if 'definitions' in info:  # pylint: disable=too-many-nested-blocks\n        for definition in info['definitions']:\n            if 'list' in definition:\n                for item in definition['list']:\n                    if 'synonyms' in item:\n                        for synonym in item['synonyms']:\n                            results.append({\"suggestion\": from_to_prefix + synonym})\n\n    infobox = \"\"\n\n    for translation in info[\"extraTranslations\"]:\n        for word in translation[\"list\"]:\n            infobox += f\"<dl><dt>{word['word']}</dt>\"\n\n            for meaning in word[\"meanings\"]:\n                infobox += f\"<dd>{meaning}</dd>\"\n\n            infobox += \"</dl>\"\n\n    results.append(\n        {\n            'infobox': result[\"translation\"],\n            'content': infobox,\n        }\n    )\n\n    return results\n", "path": "searx/engines/lingva.py"}]}