content-type

JAX-RS (Jersey 2 implementation) content negotiation with URL extension .xml or .json

妖精的绣舞 提交于 2021-02-19 03:47:07
问题 I've seen a Java RESTFUL webservice, that allowed the content-type to be requested in the URL with an extension at the end, such as .xml .json This is the style of content negotiation I am striving to achieve in my own Web Service. I am aware of the @Produces annotation, and the fact a method can resolve multiple types with the (value = {}) syntax, by adding an Accept header, say with Postman, the Chrome extension. But I'm not sure how to effectively extract out the information in one method,

PHP JSON response contains HTML headers

你离开我真会死。 提交于 2021-02-16 06:36:32
问题 I've got a strange problem where I'm trying to write a PHP page that returns some JSON to a Jquery AJAX call. Problems is that despite setting the content type to application/json, the response always seems to include the HTML header. Here's the PHP code: // some code that generates an array header("Content-type: application/json"); echo json_encode($return); Then in Javascript: $.ajax({ url: '/VAPHP/services/datatable.php', dataType: 'json', data: { type: 'invoices' }, success: function(data

Current request is not a multipart request Spring Boot and Postman (Uploading json file plus extra field)

喜夏-厌秋 提交于 2021-02-11 17:58:39
问题 I'm getting this Current request is not a multipart request error when trying to upload a json file and an extra id or dto object for my request, since this is also required to populate my database. When I am sending only the json file, everything is being uploaded fine, but now I've added the id field to the related methods and Postman, I'm getting this message and struggling to debug and fix it, if I can get any help please. These are the pieces involved: @Controller @RequestMapping("/api

How to Post “multipart/form-data” Form and get the Text field values from the Node.js server?

孤者浪人 提交于 2021-02-11 12:22:06
问题 Í'm trying to upload a file using multer. I can upload the file but somehow unable to get the text box values inside the form with the content/type "multipart/form-data". <div class="container"> <h1>File Upload</h1> <form action="/upload" method="POST" enctype="multipart/form-data" > <div class="file-field input-field"> <div class="btn grey"> <span>File</span> <input name="myImage" type="file" multiple="multiple"> </div> <div class="file-path-wrapper"> <input class="file-path validate" type=

IIS 6 - Classic ASP - Set *.asp response header's content-type to “text/html;charset=UTF-8”

半世苍凉 提交于 2021-02-04 17:40:53
问题 How do I can set *.asp files (Classic ASP) in a Web Site under IIS to have Response Header's Content-Type set to text/html;charset=UTF-8 ? Right now, the files are served as Content-Type=text/html . An alternate approach is to add <% Response.Charset = "UTF-8" %> to every single page, but I wonder if there's a way to do it globally. Thanks! -K 回答1: There is no means to globally specify the CharSet for an application. There is actually more to it than just telling the client its getting UTF-8.

Serving XHTML and self-closing tags

帅比萌擦擦* 提交于 2021-01-29 16:18:52
问题 I am trying to follow the xhtml 1.0 strict standard as I am creating my website. Right now, validator.w3.org validates my document as valid, following the XHTML 1.0 Strict standard. Here is a code-example: <div style="color:#f00"><div style="color:#00f" />Text should be red and not blue</div> Unfortunately, Firefox, Chrome and Internet Explorer parses the document incorrectly: They all seem to ignore the closing statement of my self-closing tags (mostly <div />, <li /> and some other tags),

fetch ImageData - Missing boundary in multipart/form-data - Patch

跟風遠走 提交于 2021-01-29 11:22:13
问题 There are thousands of questions similar to this one but somehow I failed to find my answer. Some of them like this suggest setting the Content-Type to undefined . Others suggest removing the Content-Type like this. I tried both. If I set the Content-Type to multipart/form-data , I face with Failed to read the request form. Missing content-type boundary. . I even tried to add custom boundaries like multipart/form-data; boundary=--XXX-- and faced with Failed to read the request form. Multipart

req.body is empty in Node

こ雲淡風輕ζ 提交于 2021-01-28 22:08:51
问题 React (Client) sent post data through axios. but req.body is empty in Node server side. Tried to use body-parser. but failed. attached client side here attached server code here This is client Axios part 回答1: It should be the Content-Type on the request. Per default the body-parser "urlencoded" handles only the following: Content-Type: application/x-www-form-urlencoded; You can set the type so: app.use(bodyParser.urlencoded({ extended: true, type: 'multipart/form-data' })) But then you have

Force Content Type with sendmail

只谈情不闲聊 提交于 2021-01-28 14:23:19
问题 I got a little problem when sending mail with sendmail: each mail are sent with Content-Type: multipart/alternative but I wonder to send my mail only in Content-Type: text/plain . The reason is because of GMAIL web interface respect the RFC, my message is displayed with the latest Content-type but because my message is not in HTML, the display is awful. My bash script is as following: #!/bin/bash SENDMAIL_BIN='/usr/sbin/sendmail' FROM_MAIL_ADDRESS='noreply@plop.com' FROM_MAIL_DISLAY='Test

How to set http.ResponseWriter Content-Type header globally for all API endpoints?

偶尔善良 提交于 2021-01-20 16:25:49
问题 I am new to Go and I'm building a simple API with it now: package main import ( "encoding/json" "fmt" "github.com/gorilla/mux" "github.com/gorilla/handlers" "log" "net/http" ) func main() { port := ":3000" var router = mux.NewRouter() router.HandleFunc("/m/{msg}", handleMessage).Methods("GET") router.HandleFunc("/n/{num}", handleNumber).Methods("GET") headersOk := handlers.AllowedHeaders([]string{"Authorization"}) originsOk := handlers.AllowedOrigins([]string{"*"}) methodsOk := handlers