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.

WARNING: Invalid HTTP request received. Only when running GET request from inside of Excel

See original GitHub issue

I am trying to write an Excel addin that uses node.js to make a GET request to a fastapi/uvicorn server on localhost. Below is the function I wrote:

function getData() {
    //You can change this URL to any web request you want to work with.
    const http = require('http');
    const options = {
      hostname: 'localhost',
      port: 8000,
      path: '/1/2/3/4',
      method: 'GET'
    };

    const req = http.request(options, res => {
      res.on('data', d => {
        process.stdout.write(d)
      })
    })
    req.on('error', error => {
      console.error(error)
    })

    req.end()
}

If I run this in a terminal with node, it runs fine and shows a 200 response on the server. If I try running the function from within Excel as a UDF, it displays 0 in the cell and the server gives the following traceback:

WARNING:  Invalid HTTP request received.
Traceback (most recent call last):
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 172, in handle_events
    event = self.conn.next_event()
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_connection.py", line 443, in next_event
    exc._reraise_as_remote_protocol_error()
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
    raise self
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_connection.py", line 425, in next_event
    event = self._extract_next_receive_event()
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_connection.py", line 367, in _extract_next_receive_event
    event = self._reader(self._receive_buffer)
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_readers.py", line 72, in maybe_read_from_IDLE_client
    matches = validate(
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_util.py", line 88, in validate
    raise LocalProtocolError(msg)
h11._util.RemoteProtocolError: illegal request line: bytearray(b'\x16\x03\x01\x02\x00\x01\x00\x01\xfc\x03\x03\xb2vs;\xdaP\xfb[\x17o\xbb\x9d:>\x12@\xe2\xd8\xae\xfa5H\x0e\xac\xb9"d\xe8\x89\xd4No  \xb2\x98\xb5\xd9\xe5\x93?\xdeT\xbf\xa5Q\xf4\xac9\x19\x81?]\x05\x14\x1at\xf5\xca\xde\xbd\xea\xa2\xe7l\x008')
WARNING:  Invalid HTTP request received.
Traceback (most recent call last):
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 172, in handle_events
    event = self.conn.next_event()
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_connection.py", line 443, in next_event
    exc._reraise_as_remote_protocol_error()
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
    raise self
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_connection.py", line 425, in next_event
    event = self._extract_next_receive_event()
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_connection.py", line 367, in _extract_next_receive_event
    event = self._reader(self._receive_buffer)
  File "/Users/rgodbey/Desktop/spade/venv/lib/python3.8/site-packages/h11/_readers.py", line 68, in maybe_read_from_IDLE_client
    raise LocalProtocolError("illegal request line")
h11._util.RemoteProtocolError: illegal request line

My thought is that somehow Excel is doing something to the GET request. Any help in debugging this is appreciated! I am unsure how to log the GET request so I can see what is happening.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Kludexcommented, Jan 31, 2022

Yeah, this was brought upon https://github.com/encode/uvicorn/pull/205

1reaction
f11rcommented, Aug 4, 2021
WARNING:  Invalid HTTP request received.
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 136, in handle_events
    event = self.conn.next_event()
  File "/usr/local/lib/python3.9/site-packages/h11/_connection.py", line 443, in next_event
    exc._reraise_as_remote_protocol_error()
  File "/usr/local/lib/python3.9/site-packages/h11/_util.py", line 76, in _reraise_as_remote_protocol_error
    raise self
  File "/usr/local/lib/python3.9/site-packages/h11/_connection.py", line 425, in next_event
    event = self._extract_next_receive_event()
  File "/usr/local/lib/python3.9/site-packages/h11/_connection.py", line 367, in _extract_next_receive_event
    event = self._reader(self._receive_buffer)
  File "/usr/local/lib/python3.9/site-packages/h11/_readers.py", line 72, in maybe_read_from_IDLE_client
    matches = validate(
  File "/usr/local/lib/python3.9/site-packages/h11/_util.py", line 88, in validate
    raise LocalProtocolError(msg)
h11._util.RemoteProtocolError: illegal request line: bytearray(b'GET /teams?q=fc G HTTP/1.1')

Everything worked once we had the client escape the space in the URL (/teams?g=fc%20G).

Read more comments on GitHub >

github_iconTop Results From Across the Web

WARNING: Invalid HTTP request received ... - Microsoft Learn
I am trying to write an Excel addin that uses node.js to make a GET request to a fastapi/uvicorn server on localhost.
Read more >
WARNING: Invalid HTTP request received. Only when running ...
I am trying to write an Excel addin that uses node.js to make a GET request to a fastapi/uvicorn server on localhost.
Read more >
Invalid HTTP request received with Fast API - Stack Overflow
I have a React front end making requests to ...
Read more >
A Complete Guide and List of HTTP Status Codes
A complete list of HTTP status codes with explaination of what they are, why they occur and what you can do to fix...
Read more >
Content-Disposition - HTTP - MDN Web Docs
In a regular HTTP response, the Content-Disposition response header ... Request header, Response header (for a subpart of a multipart body).
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