Git Product home page Git Product logo

Comments (7)

textrix avatar textrix commented on August 22, 2024 1

It's not a case-sensitivity issue with content-type. The problem seems to be that the cfg.headers['content-type'] statement returns undefined because the headers in the routing endpoint's request are not a plain map.
This is because busboy is not getting the value in the form of headers.get('content-type'), but using index brackets. To make it more convenient, it seems like a good idea to ask busboy authors to use headers.get.

In a nutshell, try this:

    const simpleHeaders = {};
    for (const key of request.headers.keys()) {
        simpleHeaders[key] = request.headers.get(key);
    }

    const busboy = Busboy({ headers: simpleHeaders });

or

    const busboy = Busboy({ headers: Object.fromEntries(request.headers) });

from busboy.

mscdex avatar mscdex commented on August 22, 2024

Have you checked the contents of event.headers to know what is the proper casing? It must be something other than the two you're attempting to access.

from busboy.

yogeshzairfoil avatar yogeshzairfoil commented on August 22, 2024

@mscdex I logged it. It is lower case
image

from busboy.

yogeshzairfoil avatar yogeshzairfoil commented on August 22, 2024
headers: {
        ...event.headers,
        "Content-Type":
          event.headers["Content-Type"] || event.headers["content-type"],
      }```
      
      I tried updating the string here to have to exactly same case the error is mentioning.

from busboy.

mscdex avatar mscdex commented on August 22, 2024

I don't know what to tell you then as event.headers seems to already have only lowercased header names. The only way you can get the "Missing Content-Type" error is if the headers object you pass to busboy is a non-object, null, or if headers['content-type'] is not a string.

Just to double check, what does typeof event.headers['content-type'] show?

from busboy.

yogeshzairfoil avatar yogeshzairfoil commented on August 22, 2024

It logs back as string

I really feel there might be something on Busboy's end that is messing this up. I think people still have these problems with lamda functions - saw that when I was going through all the issues here

@mscdex

from busboy.

mscdex avatar mscdex commented on August 22, 2024

Well, you'll need to dig into the code and troubleshoot it yourself then because I have no explanation as to why you're receiving that particular error in this case.

from busboy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.