Difference between application/x-javascript and text/javascript content types

The JavaScript MIME Type When sending JavaScript content, you should use text/javascript as per RFC 9239. Aliases application/javascript, application/x-javascript, text/javascript1.0, text/javascript1.1, text/javascript1.2, text/javascript1.3, text/javascript1.4, text/javascript1.5, text/jscript, and text/livescript are deprecated aliases for it. If you are writing a tool which consumes JavaScript (e.g. an HTTP client) then you should consider supporting them for backwards compatibility. … Read more

Determine file type in Ruby

There is a ruby binding to libmagic that does what you need. It is available as a gem named ruby-filemagic: gem install ruby-filemagic Require libmagic-dev. The documentation seems a little thin, but this should get you started: $ irb irb(main):001:0> require ‘filemagic’ => true irb(main):002:0> fm = FileMagic.new => #<FileMagic:0x7fd4afb0> irb(main):003:0> fm.file(‘foo.zip’) => “Zip archive … Read more

Slack incoming webhook: Request header field Content-type is not allowed by Access-Control-Allow-Headers in preflight response

That Slack API endpoint unfortunately appears to be broken in its handling of cross-origin requests from frontend JavaScript code—in that it doesn’t handle the CORS preflight OPTIONS request as it should—so the only solution seems to be to omit the Content-Type header. So it looks like you need to remove the following from the headers … Read more

Spring MVC 4: “application/json” Content Type is not being set correctly

First thing to understand is that the RequestMapping#produces() element in @RequestMapping(value = “/json”, method = RequestMethod.GET, produces = “application/json”) serves only to restrict the mapping for your request handlers. It does nothing else. Then, given that your method has a return type of String and is annotated with @ResponseBody, the return value will be handled … Read more

Http Post with request content type form not working in Spring MVC 3

Unfortunately FormHttpMessageConverter (which is used for @RequestBody-annotated parameters when content type is application/x-www-form-urlencoded) cannot bind target classes (as @ModelAttribute can). Therefore you need @ModelAttribute instead of @RequestBody. If you don’t need to pass different content types to that method you can simply replace the annotation: @RequestMapping(method = RequestMethod.POST) public ModelAndView create(@ModelAttribute UserAccountBean account) { … … Read more