Json content type on multipart - paw-app

On a same HTTP request, I upload files and a JSON body. I do this by using a form/multipart.
It its very convenient for files, but it is ugly for the JSON. Here is a screenshot of my request panel.
Is there an easier way to add a Text JSON content type on the request, using a Text JSON tag for example ?

Related

How I can block some of the HTTP headers fields?

For example the page is sending a 'link' http headers field that I don't want to load an async CSS from. How can I block it? Is it possible that I get those headers, remove the LINK field from it, and then page will load without this addition CSS (non-placed in page body)?
I have tried to modify the headers to no avail.
request('https://www.google.com', function(err, resp, data){
if (resp.statusCode == 200) {
console.log(resp.headers); // headers
}
else {console.log(err);}
});
Request is a node.js module. I need to modify headers before they are loaded by browser (passing modified headers by 'render' with combination of ejs template is not working).
Yes, its possible to remove the css and js links (they are not headers) from the html response and just display the result using jsdom or cheerio.
Update: The OP is talking about "Web Linking", the RFC5988 stuff on prefetch resource with HTTP response header, and want to block such prefetch behaviour.
In order to do that, a proxy can be made manually, block all unwanted data, and only return HTTP headers and content of interest. For example:
router.get('/proxy-to-google', function(req, res) {
request('https://www.google.com', function(err, resp, data) {
// get interested headers from resp object, and set it in res
res.set('Example-Header', 'XXX');
...
res.send(data);
});
});
There are 3 types of head/header in the world of web, and it seems you have confused with these concepts.
HTTP header. These are the header information delivered in HTTP request and response. In the example of question, the HTTP response headers are printed.
<header> element in HTML. These are visible element exists in HTML page body, mostly used to wrap elements such as title, navigation bar etc.
<head> element in HTML. This is the meta element of HTML document. It is not visible in page, but rather responsible to mark important information of HTML document, such as CSS stylesheet links, JavaScript file URLs etc.
In your case, you are trying to block the 3rd kind of "head" above, and you can make it using #Zuei Zukenberg's proposal. This <head> element has nothing to do with HTTP headers.

how to get url mime type in qtwebkit networkaccessmanager

I want to get all css urls in QNetworkAccessManager in order to load the css url from database.
The easy solution to get the request's MIME type is by url path extensions, unfortunately this is not always the case.
how can I get the link resouce's type(css or img etc) or link resource's attribute like img/link/rel/type? seems like there is no interface to get CachedResource..

ASP.Net WebAPI MediaTypeMapping using Body Content

Is it possible (or sensible) to build a custom MediaTypeMapping to select a MediaTypeFormatter based on content from the Request Body?
I'm thinking specifically of a case where I have a very non-descriptive text/plain in a multipart/form-data payload and I want to use heuristics to work out what's contained.
I'm currently doing this in a custom MediaTypeFormatter that looks at the first few lines, and if the content begins with { then it assumes JSON, if it's word,word,word the the commas indicate CSV.
I was thinking that a MediaTypeMapping would be cleaner but I don't know if it's sensible to try and match from the Body content.
Currently there is no way you can really Inspect content in Webapi. You can not read the stream more than once.

Returns text instead of image

I am trying to download following comics:
http://comicsbook.ru/upload/Комикс-Amazing-Super-Powers-Минутка-наркомании-81619.jpg
Sorry for url, but it is just image. You can easily look it in browser, even download via browser, but if I wget this url, I get html page, not image. What do I do wrong? I also tried perl download module. Same result.
if the referer is not set in the request, the server is redirecting(301) to a web page
I was able to get the jpg image by referer in header to: http://comicsbook.ru/funny/81619?minutka-narkomanii
wget --referer="http://comicsbook.ru/funny/81619?minutka-narkomanii" http://comicsbook.ru/upload/Комикс-Amazing-Super-Powers-Минутка-наркомании-81619.jpg
It means the default content-type is text/html.
You have to set the content type you want through the setContentType() method of your corresponding library. Here is an example in java
HttpGet request = new HttpGet(URL);
request.addHeader("accept", "image/jpeg");

Umbraco - Check if request is XmlHttpRequest

I'm doing an AJAX feature for my Umbraco website.
Basically what I'm trying to do is when someone requests for http://mysite.com/news with the XmlHttpRequest header then I want Umbraco to return JSON of the following page.
What I've been trying to do is finding the right place to check for the header in Umbraco. Basically I want to override or inherit some class where I could check the header and return the page in Json or HTML depending on the header.
I'm using Umbraco 4.7.0 (1.0.4090.21631)
Any feedback would be more than welcome! Thanks!
I'd probably use the URL Rewriting module for IIS7 to detect the content-type in the request, then redirect to the same URL with /jsonTemplate on the end of it. You would then create a masterpage called jsonTemplate, with a single macro inside it, which would return your JSON.
This is common for Umbraco - specifying a separate template with a separate macro to return a different view of the same content. Check out http://blog4umbraco.codeplex.com/SourceControl/changeset/view/68424#1138733 for an example of an XSLT macro that returns RSS using this approach.
You should check the Content-Type header from server side logic. Your Javascript should be specifying a Content-Type like application/json.

Resources