You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
0.32.3 - intercept{String,Buffer}Protocol mimeType not transfered to content-type response header #2788
Using interceptStringProtocol, the mimeType of the object passed to the callback is not transferred back to the renderer's HTTP response headers.
For example, my renderer's application uses jQuery to make and XHR request and it's supposed to get JSON. jQuery inspects the HTTP response headers to get the content-type:
$.get("/api/get-json",function__cb(data){if(typeofdata!=='object')throw'Unexpected type';// process the object... });
The URL /api/get-json is intercepted as follow:
app.on('ready',function(){varprotocol=require("protocol");protocol.interceptStringProtocol('http',function(request,callback){if(request.url.indexOf("/api/get-json")>=0){// Send back some JSONcallback({mimeType: "application/json",data: '{"value": 1}',charset: 'utf-8'});}else{// get some contents}});// create the window and load my url});
Just as a dummy test, I forced the HTTP response headers to contain content-type: application/json my modifying the previously linked method and the behavior of the client-side application becomes identical as any other web browser: the string gets parsed as JSON and an object is sent back.
Activity