All Projects → mirage → typebeat

mirage / typebeat

Licence: MIT license
Parsing of the Content-Type header in pure OCaml

Programming Languages

ocaml
1615 projects
Makefile
30231 projects

Projects that are alternatives of or similar to typebeat

bcp-47
Parse and stringify BCP 47 language tags
Stars: ✭ 51 (+155%)
Mutual labels:  iana
emile
& images
Stars: ✭ 29 (+45%)
Mutual labels:  rfc822
media-type
JavaScript module to parse and validate RFC6838 media types, anything from 'text/plain' to 'application/vnd.company.app.entity-v2+xml;charset=utf8'
Stars: ✭ 15 (-25%)
Mutual labels:  content-type
port-numbers
Get information on network port numbers and services, based on IANA's public listing
Stars: ✭ 22 (+10%)
Mutual labels:  iana
get-trust-anchor
Tool for fetching/refreshing DNS Root Zone trust anchors
Stars: ✭ 57 (+185%)
Mutual labels:  iana
bcp-47-normalize
Normalize, canonicalize, and format BCP 47 tags
Stars: ✭ 16 (-20%)
Mutual labels:  iana
tz
Time zone support for Elixir
Stars: ✭ 73 (+265%)
Mutual labels:  iana
liwasc
List, wake and scan nodes in a network.
Stars: ✭ 129 (+545%)
Mutual labels:  iana
ruby-magic
Simple interface to libmagic for Ruby Programming Language
Stars: ✭ 23 (+15%)
Mutual labels:  content-type
mimesniffer
A MIME type sniffer for Go.
Stars: ✭ 22 (+10%)
Mutual labels:  content-type
Nodemailer
✉️ Send e-mails with Node.JS – easy as cake!
Stars: ✭ 14,354 (+71670%)
Mutual labels:  rfc822
ESP-Mail-Client
⚡️Arduino Mail Client Library to send, read and get incoming mail notification for ESP32, ESP8266 and SAMD21 devices. The library also supported other Arduino devices using Clients interfaces e.g. WiFiClient, EthernetClient, and GSMClient.
Stars: ✭ 78 (+290%)
Mutual labels:  rfc822

TypeBeat - Agnostic parser of the Content-Type in OCaml

Build Status

TypeBeat is a pure implementation of the parsing of the Content-Type's value (see RFC822 and RFC2045). The reason of this light library is to compute a complex rule. Indeed, it's hard to parse the value of the Content-Type, believe me.

So it's a common library if you want to know the value of the Content-Type and don't worry, we respect the standard. We saved the IANA database too.

Instalation

TypeBeat can be installed with opam:

opam install type-beat

Explanation

TypeBeat uses the cool and funny Angstrom library to parse the value of the Content-Type. If you want to implement an email parser (like MrMime) or an HTTP server (CoHTTP), firstly, these already exist, too bad.

This parser handles complex rules like the CFWS token and other weird rules from old and stupid RFCs. The point is to centralize all these parsers in one library (because you can find the Content-Type crazy rule in some different protocols) .

Then, the API was designed to be easy to use:

val of_string : string -> (content, error) result
val of_string_raw : string -> int -> int -> (content * int, error) result

The first transforms its string argument into a Content-Type value. The second is generally used by another parser (like an HTTP protocol parser) to parse a part of the string and return how many bytes the parser consumed.

If you are a warrior of the Angstrom library, you can use the parser:

val parser : content Angstrom.t

But the parser does not terminate because we have the CFWS token at the end. What does that mean? The parser expects an End of input or any character other than wsp (and you can produce that by Angstrom.Unbuffered.Complete) to check that the hypothetical next line is a new field. Because, as you know, we can write something like:

Content-Type: text/html;^CRLF
 charset="utf-8"

And it is still valid (see RFC822)!

Another point is that this library has all of the IANA media types database (dated 2016-06-01), so we recognize the IANA media types automatically.

Build Requirements

  • OCaml >= 4.01.0
  • Angstrom
  • topkg, ocamlfind and ocamlbuild to build the project

Improvement

If you want something from the RFC822, I can provide that in this library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].