Skip to content

Debugger.js exception for HTTP requests with no Content-Type #4419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
milannankov opened this issue Jun 19, 2017 · 5 comments · Fixed by #4754
Closed

Debugger.js exception for HTTP requests with no Content-Type #4419

milannankov opened this issue Jun 19, 2017 · 5 comments · Fixed by #4754

Comments

@milannankov
Copy link

Hello,

I am getting an error in debugger.js when debugging my app. The app sends HTTP requests some of which happen to have no "Content-Type". This seems to be causing the error.

Error: Error while parsing debug 'response' object. mimeType: string value expected.

Debugger.ts contains the following code:
let mimeType: string = <string>headers["Content-Type"] || <string>headers["content-type"];

So there will be no mimeType for requests with no "Content-Type". Locally I have temporarily fixed the problem by providing an empty string if no "Content-Type" is specified.

let mimeType: string = <string>headers["Content-Type"] || <string>headers["content-type"] || '';

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.0.3

  • Cross-platform modules: 3.1.0-2017-06-16-6999 or 3.0.1

  • Runtime(s): 3.0.1

Please tell us how to recreate the issue in as much detail as possible.

  1. Unzip the sample
  2. Run the http server - node .\server\index.js
  3. Add Android platform to the app - HelloWorld
  4. Update main-page.js to hit the correct URL
  5. Run the app in debug mode using VS Code
  6. Click the button

bug-http.zip

@NickIliev
Copy link
Contributor

The issue is only reproducible when using local node server (as in the posted example above).

@R4ZuL
Copy link

R4ZuL commented Jun 25, 2017

+1

NativeScript-Angular V3.0.3

I am using ASP.NET Core Web API services for my backend. The application crashs if one of my services returns a http status code that doesn't include content for example 404 - Not Found

@joshcomley
Copy link
Contributor

joshcomley commented Jun 26, 2017

I have the same issue, with the same environment as @R4ZuL

@joshcomley
Copy link
Contributor

Hacky fix for now, I just modified line 15 of debugger.js in my node_modules to:

    var mimeType = headers["Content-Type"] || headers["content-type"] || "text/plain";

hshristov pushed a commit that referenced this issue Aug 25, 2017
mimeTpye set to "application/octet-stream" according to RFC if content-type is not specified.
See: http://mattryall.net/blog/2008/03/default-content-type, https://stackoverflow.com/questions/1176022/unknown-file-type-mime
@ghost ghost assigned hshristov Aug 25, 2017
@ghost ghost added the in progress label Aug 25, 2017
@hshristov hshristov removed the backlog label Aug 25, 2017
@hshristov hshristov added this to the 3.2 milestone Aug 25, 2017
hshristov pushed a commit that referenced this issue Aug 25, 2017
mimeTpye set to "application/octet-stream" according to RFC if content-type is not specified.
See: http://mattryall.net/blog/2008/03/default-content-type, https://stackoverflow.com/questions/1176022/unknown-file-type-mime
@ghost ghost removed the in progress label Aug 25, 2017
@lock
Copy link

lock bot commented Aug 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
6 participants