How to send MIME over HTTP? - http

I need to send certain data to the server in a .zip archive, over HTTP POST request, MIME encoded. I take it that means only that I need to specify MIME type in a request header. But I'm confused as to what should I put in request's body. So far I can see two ways to do it:
Usually, as I take it (sorry, I'm not a web coder, so kinda lame with HTTP), POST request body consists of pairs parameter_name=some+data divided by '&'. Should I do it the same way and write contents of my file in base64 in one of parameters? That would also let me provide supplemental parameters.
Or should I just fill POST body with contents of my file (in base64, right?)? If so, is there any way to provide additional info about the file?
Is only one of theese ways acceptable or are both? If so, what would be the best practice?
Also, code sample in C++ for Qt would be very-very much appreciated, but totally not necessary :)

The whole key=value body in POST requests is just for when you are sending form-data to your server. If you want to POST only the contents of a .zip file you can just send that as the body of your POST, no need to set it up like a form post as you describe. You can set the following headers in the request:
Content-Type: application/zip
Content-Disposition: attachment; filename=myzip.zip
You don't even necessarily have to base64 encode the body, although you should if that's what your server is expecting.
The Content-Disposition is the thing you need to describe more about your file upload. You can find some details about it here:
http://en.wikipedia.org/wiki/MIME#Content-Disposition
and here
http://www.ietf.org/rfc/rfc2183.txt
At the server end, you just need to write some code which will get the response body in its entirity (which is straightforward, although YMMV depending on language and framework), and handle it however you want.
For a real world example, you might find it useful to look at, say, AtomPub for how this is done:
http://bitworking.org/projects/atom/rfc5023.html

Related

Documentation for Rebol2's read/custom?

I've been trying to update Ross-Gill's Twitter API for REBOL2 to support uploading media. From looking at its source, the REBOL cookbook, the codeconscious site, and other questions here, my understanding is that read/custom is the preferred way to POST data to websites.
However, I haven't been able to find any real documentation on read/custom. For example: Does it support sending multipart/form-data? (I've managed to work around this by manually composing each part, but it doesn't seem to work for all image files on Twitter's end and is a bit of a hack). Does read/custom only return text on an HTTP/1.0 200 OK response? (It appears so, which is problematic when I receive HTTP/1.0 202 Accepted and need to read the resulting data). Is there a reason that read/custom/binary doesn't appear to send binary data correctly without converting the data using to-string?
TL;DR: Is there good documentation on REBOL2's read/custom somewhere? Alternatively, is read/custom only meant for basic POSTs and I should be using ports and handling the HTTP responses manually?
You guessed right, read/custom is meant for simple HTTP posts, handling web forms data only (that is why it will fail on binary data). No official documentation for it. But that is not an issue as you can access the source code of the HTTP implementation:
probe system/schemes/HTTP
There you can see that /custom refinement supports two keywords, post and header (for setting custom HTTP headers). It also appears that even if you use both keywords, Content-Type will be forced to application/x-www-form-urlencoded no matter what (which is probably the reason why your binary data gets rejected by the server, as the provided mime type is wrong).
In order to work around that, you can save the HTTP object, modify its implementation to fit your needs and reload it.
Saving:
save %http-scheme.r system/schemes/HTTP
Reloading:
system/schemes/HTTP: do load %http-scheme.r
If you just disable the hard-coded Content-Type setting in the HTTP code, and then provide your own one using header keyword, it should work fine, even with binary data:
read/custom <url> [header [Content-Type: <...>] post <data>]
Hope this helps.

Basic CGI with Lua

I need a very light web solution to run on a Linux appliance to handle HTML forms, so intend to use uwsgi and Lua.
In the CGI script, this article uses the following code:
print ("Content-type: Text/html\n")
print ("Hello, world!")
However, this works too:
print("Status: 200 OK\r\n\r\nHello, world!\r\n")
I'd like to know what CGI scripts are really required to return to the web server.
Thank you.
You don't need a header at all, the only thing you really need is the blank line that ends the header and starts the body:
print ("\nHello, World")
should work as well.
However, you should at least include the Content-type including the character set, since browsers should default to iso-8859-1, but the user may override this, and you should use utf-8 to avoid being restricted in what characters you can display.
print("Content-type: text/html; charset=utf-8")
Also, if you're programming an appliance, you probably want to avoid caching, so i'd spend an extra
print("Cache-control: no-cache")
print("Pragma: no-cache")
which prevents browsers and proxies from caching your page.
yet you need to process HTML forms data (say POST data). You can use the power of Ajax Forms (javascript library) in order to have your POST data being sent as JSON, which you can read with io:read('*') back to your Lua script.

Using "application/octet-stream" as a content type in POST

I'm thinking about implementing an RPC mechanism over HTTP. The POST method seems to be suitable for the calls. However, since each call comes with the binary payload, there's a decision to be made about how to attach that binary data to the POST request. It seems there are two content types for POSTs of use today: application/x-www-form-urlencoded and multipart/form-data. The former seems to require percent-escaping binary data, while the latter seems to add some overhead with the boundaries/content-disposition fields.
Therefore my question is: how good is it to just use application/octet-stream as a POST content type and just include the binary payload afterwards as is? Will it go through all proxies? Will all HTTP servers be able to handle this? Is it standards-compliant? In other words, should I go for it?
Yes, you can do that; but it would be better to use a more specific type that makes the message self-descriptive.

Google search by image "image_content" format?

I'm trying to create an Application, which is able to upload an image to https://www.google.de/searchbyimage/upload. I got that working (Posting multipart/form-data via C#)
The only thing I now need to know is:
How is the image sent by the browser usually? In the multipart/form-data I found something called "image_content" in a sniffed request, what stores the image data.
But I don't know which format the image is stored.
------WebKitFormBoundaryumAjUbPr6ymfh8hM
Content-Disposition: form-data; name="image_content"
_9j_4AAQSkZJRgABAgAAAQABAAD__gAEKgD_4gv4SUNDX1BST0ZJTEUAAQEAAAvoAAAAAAIAAABtbnRyUkdCIFhZWiAH2QADABsAFQAkAB9hY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAA9tYAAQAAAADTLQAAAAAp-D3er_JVrnhC-uTKgzkNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBkZXNjAAABRAAAAHliWFlaAAABwAAAABRiVFJDAAAB1AAACAxkbWRkAAAJ4AAAAIhnWFlaAAAKaAAAABRnVFJDAAAB1AAACAxsdW1pAAAKfAAAABRtZWFzAAAKkAAAACRia3B0AAAKtAAAABRyWFlaAAAKyAAAABRyVFJDAAAB1AAACAx0ZWNoAAAK3AAAAAx2dWVkAAAK6AAAAId3dHB0AAALcAAAABRjcHJ0AAALhAAAADdjaGFkAAALvAAAACxkZXNjAAAAAAAAAB9zUkdCIElFQzYxOTY2LTItMSBibGFjayBzY2FsZWQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFlaIAAAAAAAACSgAAAPhAAAts9jdXJ2AAAAAAAABAAAAAAFAAoADwAUABkAHgAjACgALQAyADcAOwBAAEUASgBPAFQAWQBeAGMAaABtAHIAdwB8AI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BIuEXVJ0OhleR6hEeNGjCTe9uXfim5hYK9DH4mDDSPUgCe2GGfAIYMsFiIh6Zd6hYB7y6gxTh7YZxdAAyO5651w8qbwwYkKoIhj_GV8JDJEREvTP8rLRE4InncOJz_CZECsCGysyXfxnNQPCVV6-L-kKOehtNS-_jIUXYiwqGwdll1vEZfad6TaRF-_goUEss_wDrE98WCZxSXiw4a-k8KoREvTBmxk_lINhGmTKVNRMcdHjJfaSxtM7OwYjjGEzzCD0ZHble7zXRVCBBwE2m-vbAqUaOHJVMYGi8iUgjJFW0t3eoxImOtiWJSLiNEbx1l8IaukkuDV41YIWpV3KwEax-FRrjUXzHOffXm4HbeFQGyPMJpmryjTzB0Hy8sROQkf4OthCQpcNTylPa2dZHIBNJJtMREtJ4e2agxPbxWYHcofOsrWDAkLMENWHWErlIhFpKpeKISNxiRT4RIYiqWkl9nrhQYjapPMTebMX2oUioMvB09uLmWJpgzMp2KPRxj4CZNEbQTKEBO2Y5nQ8R-QdeVluREN4lFw9dsEzWM1ou0Rh5G83hrTp_A6w0uoKCUF4nqYjDMBQpSTnbvG95QQAwpUKRVpzcZAejm7RJOYj3DmrMk2wUFh5NWE9G_Uk1CaiG9RLV7moOSoQiR4Ro2T5ZMSS2oQNeYvrkzOc2bcz_AJiqwmAEC46ExqXI_TIIRVG4qjqiS3eLQKi2kQSxs_PMWxQVMmjaIjU3z0MogUAFEyXqqnruI5xCAj6kA1HWy8Itl-XYZNbx_V60V7f_AEv_2Q==
------WebKitFormBoundaryumAjUbPr6ymfh8hM
Any suggestions?
The default encoding is base64. You should form a request that matches your sniffed request, except for the following:
The WebKitFormBoundaryumAj... string should have a random string appended to ensure its uniqueness
The _9j_ line should be replaced with the base64-encoded contents of the image you are uploading.
The server will automatically detect the type of file (JPG, PNG, etc) so you shouldn't need to worry about that.
This is base64 encoded image. You can actually use it in many places, such as in CSS and in JavaScript. You can basically place it anywhere, where usual URI would be required. You can also encode many different things in such way (typefaces used in #font-face, for example).
In most modern computer languages there is built in functionality for base64 encoding – just google for one in C# if that's what you're using.
You can read more on the usage of data-URIs here: https://developer.mozilla.org/en-US/docs/data_URIs and perhaps here: http://css-tricks.com/data-uris/

RESTful URLs and folders

On the Microformats spec for RESTful URLs:
GET /people/1
return the first record in HTML format
GET /people/1.html
return the first record in HTML format
and /people returns a list of people
So is /people.html the correct way to return a list of people in HTML format?
If you just refer to the URL path extension, then, yes, that scheme is the recommended behavior for content negotiation:
path without extension is a generic URL (e.g. /people for any accepted format)
path with extension is a specific URL (e.g. /people.json as a content-type-specific URL for the JSON data format)
With such a scheme the server can use content negotiation when the generic URL is requested and respond with a specific representation when a specific URL is requested.
Documents that recommend this scheme are among others:
Cool URIs don't change
Cool URIs for the Semantic Web
Content Negotiation: why it is useful, and how to make it work
You have the right idea. Both /people and /people.html would return HTML-formatted lists of people, and /people.json would return a JSON-formatted list of people.
There should be no confusion about this with regard to applying data-type extensions to "folders" in the URLs. In the list of examples, /people/1 is itself used as a folder for various other queries.
It says that GET /people/1.json should return the first record in JSON format. - Which makes sense.
URIs and how you design them have nothing to do with being RESTful or not.
It is a common practice to do what you ask, since that's how the Apache web server works. Let's say you have foo.txt and foo.html and foo.pdf, and ask to GET /foo with no preference (i.e. no Accept: header). A 300 MULTIPLE CHOICES would be returned with a listing of the three files so the user could pick. Because browsers do such marvelous content negotiation, it's hard to link to an example, but here goes: An example shows what it looks like, except for that the reason you see the page in the first place is the different case of the file name ("XSLT" vs "xslt").
But this Apache behaviour is echoed in conventions and different tools, but really it isn't important. You could have people_html or people?format=html or people.html or sandwiches or 123qweazrfvbnhyrewsxc6yhn8uk as the URI which returns people in HTML format. The client doesn't know any of these URIs up front, it's supposed to learn that from other resources. A human could see the result of All People (HTML format) and understand what happens, while ignoring the strange looking URI.
On a closing note, the microformats URL conventions page is absolutely not a spec for RESTful URLs, it's merely guidance on making URIs that apparently are easy to consume by various HTTP libraries for some reason or another, and has nothing to do with REST at all. The guidelines are all perfectly OK, and following them makes your URIs look sane to other people that happen to glance on the URIs (/sandwiches is admittedly odd). But even the cited AtomPub protocol doesn't require entries to live "within" the collection...

Resources