Skip to content
On this page

Constants

HTTP Methods

c
typedef enum {
  YS_METHOD_GET = 1,
  YS_METHOD_POST,
  YS_METHOD_PUT,
  YS_METHOD_PATCH,
  YS_METHOD_DELETE,
  YS_METHOD_OPTIONS,
  YS_METHOD_HEAD,
  YS_METHOD_CONNECT,
  YS_METHOD_TRACE
} ys_http_method;

The ys_http_method enum is used to reference HTTP methods in Ys' APIs. If you need a string literal of the method, use ys_http_method_names e.g.

c
char* get_str = ys_http_method_names[YS_METHOD_GET]; // "GET"

HTTP Status Codes

c
typedef enum {
  YS_STATUS_CONTINUE = 100,
  YS_STATUS_SWITCHING_PROTOCOLS = 101,
  YS_STATUS_PROCESSING = 102,
  YS_STATUS_EARLY_HINTS = 103,

  YS_STATUS_OK = 200,
  YS_STATUS_CREATED = 201,
  YS_STATUS_ACCEPTED = 202,
  YS_STATUS_NON_AUTHORITATIVE_INFO = 203,
  YS_STATUS_NO_CONTENT = 204,
  YS_STATUS_RESET_CONTENT = 205,
  YS_STATUS_PARTIAL_CONTENT = 206,
  YS_STATUS_MULTISTATUS = 207,
  YS_STATUS_ALREADY_REPORTED = 208,
  YS_STATUS_IM_USED = 226,

  YS_STATUS_MULTIPLE_CHOICES = 300,
  YS_STATUS_MOVED_PERMANENTLY = 301,
  YS_STATUS_FOUND = 302,
  YS_STATUS_SEE_OTHER = 303,
  YS_STATUS_NOT_MODIFIED = 304,
  YS_STATUS_USE_PROXY = 305,
  YS_STATUS_NULL_ = 306,
  YS_STATUS_TEMPORARY_REDIRECT = 307,
  YS_STATUS_PERMANENT_REDIRECT = 308,

  YS_STATUS_BAD_REQUEST = 400,
  YS_STATUS_UNAUTHORIZED = 401,
  YS_STATUS_PAYMENT_REQUIRED = 402,
  YS_STATUS_FORBIDDEN = 403,
  YS_STATUS_NOT_FOUND = 404,
  YS_STATUS_YS_METHOD_NOT_ALLOWED = 405,
  YS_STATUS_NOT_ACCEPTABLE = 406,
  YS_STATUS_PROXY_AUTH_REQUIRED = 407,
  YS_STATUS_REQUEST_TIMEOUT = 408,
  YS_STATUS_CONFLICT = 409,
  YS_STATUS_GONE = 410,
  YS_STATUS_LENGTH_REQUIRED = 411,
  YS_STATUS_PRECONDITION_FAILED = 412,
  YS_STATUS_REQUEST_ENTITY_TOO_LARGE = 413,
  YS_STATUS_REQUEST_URI_TOO_LONG = 414,
  YS_STATUS_UNSUPPORTED_MEDIA_TYPE = 415,
  YS_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE = 416,
  YS_STATUS_EXPECTATION_FAILED = 417,
  YS_STATUS_TEAPOT = 418,
  YS_STATUS_MISDIRECTED_REQUEST = 421,
  YS_STATUS_UNPROCESSABLE_ENTITY = 422,
  YS_STATUS_LOCKED = 423,
  YS_STATUS_FAILED_DEPENDENCY = 424,
  YS_STATUS_TOO_EARLY = 425,
  YS_STATUS_UPGRADE_REQUIRED = 426,
  YS_STATUS_PRECONDITION_REQUIRED = 428,
  YS_STATUS_TOO_MANY_REQUESTS = 429,
  YS_STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
  YS_STATUS_UNAVAILABLE_FOR_LEGAL_REASONS = 451,

  YS_STATUS_INTERNAL_SERVER_ERROR = 500,
  YS_STATUS_NOT_IMPLEMENTED = 501,
  YS_STATUS_BAD_GATEWAY = 502,
  YS_STATUS_SERVICE_UNAVAILABLE = 503,
  YS_STATUS_GATEWAY_TIMEOUT = 504,
  YS_STATUS_HTTP_VERSION_NOT_SUPPORTED = 505,
  YS_STATUS_VARIANT_ALSO_NEGOTIATES = 506,
  YS_STATUS_INSUFFICIENT_STORAGE = 507,
  YS_STATUS_LOOP_DETECTED = 508,
  YS_STATUS_NOT_EXTENDED = 510,
  YS_STATUS_NETWORK_AUTHENTICATION_REQUIRED = 511,
} ys_http_status;

If you need a string literal of the status, use ys_http_status_names e.g.

c
char* get_str = ys_http_status_names[YS_STATUS_BAD_REQUEST]; // "Bad Request"

MIME Type Constants

c
extern const*
namevalue
YS_MIME_TYPE_3GPvideo/3gpp
YS_MIME_TYPE_3GPPvideo/3gpp
YS_MIME_TYPE_7Zapplication/x-7z-compressed
YS_MIME_TYPE_AIapplication/postscript
YS_MIME_TYPE_APNGimage/apng
YS_MIME_TYPE_ASFvideo/x-ms-asf
YS_MIME_TYPE_ASXvideo/x-ms-asf
YS_MIME_TYPE_ATOMapplication/atom+xml
YS_MIME_TYPE_AVIvideo/x-msvideo
YS_MIME_TYPE_AVIFimage/avif
YS_MIME_TYPE_BINapplication/octet-stream
YS_MIME_TYPE_BMPimage/x-ms-bmp
YS_MIME_TYPE_CCOapplication/x-cocoa
YS_MIME_TYPE_CRTapplication/x-x509-ca-cert
YS_MIME_TYPE_CSStext/css
YS_MIME_TYPE_CSVtext/csv
YS_MIME_TYPE_CURimage/x-icon
YS_MIME_TYPE_DEBapplication/vnd.debian.binary-package
YS_MIME_TYPE_DERapplication/x-x509-ca-cert
YS_MIME_TYPE_DLLapplication/vnd.microsoft.portable-executable
YS_MIME_TYPE_Dmgapplication/octet-stream
YS_MIME_TYPE_DOCapplication/msword
YS_MIME_TYPE_DOCXapplication/vnd.openxmlformats-officedocument.wordprocessingml.document;
YS_MIME_TYPE_EARapplication/java-archive
YS_MIME_TYPE_EOTapplication/vnd.ms-fontobject
YS_MIME_TYPE_EPSapplication/postscript
YS_MIME_TYPE_EPUBapplication/epub+zip
YS_MIME_TYPE_EXEapplication/vnd.microsoft.portable-executable
YS_MIME_TYPE_FLVvideo/x-flv
YS_MIME_TYPE_GEOJSONapplication/geo+json
YS_MIME_TYPE_GIFimage/gif
YS_MIME_TYPE_GLBmodel/gltf-binary
YS_MIME_TYPE_GLTFmodel/gltf+json
YS_MIME_TYPE_HQXapplication/mac-binhex40
YS_MIME_TYPE_HTCtext/x-component
YS_MIME_TYPE_HTMtext/html
YS_MIME_TYPE_HTMLtext/html
YS_MIME_TYPE_ICOimage/x-icon
YS_MIME_TYPE_IMGapplication/octet-stream
YS_MIME_TYPE_ISOapplication/octet-stream
YS_MIME_TYPE_JADtext/vnd.sun.j2me.app-descriptor
YS_MIME_TYPE_JARapplication/java-archive
YS_MIME_TYPE_JARDIFFapplication/x-java-archive-diff
YS_MIME_TYPE_JNGimage/x-jng
YS_MIME_TYPE_JNLPapplication/x-java-jnlp-file
YS_MIME_TYPE_JP2image/jp2
YS_MIME_TYPE_JPEGimage/jpeg
YS_MIME_TYPE_JPGimage/jpeg
YS_MIME_TYPE_JStext/javascript
YS_MIME_TYPE_JSONapplication/json
YS_MIME_TYPE_JSONLDapplication/ld+json
YS_MIME_TYPE_JXLimage/jxl
YS_MIME_TYPE_JXRimage/jxr
YS_MIME_TYPE_KARaudio/midi
YS_MIME_TYPE_KMLapplication/vnd.google-earth.kml+xml
YS_MIME_TYPE_KMZapplication/vnd.google-earth.kmz
YS_MIME_TYPE_M3U8application/vnd.apple.mpegurl
YS_MIME_TYPE_M4Aaudio/x-m4a
YS_MIME_TYPE_M4Vvideo/x-m4v
YS_MIME_TYPE_MDtext/markdown
YS_MIME_TYPE_MIDaudio/midi
YS_MIME_TYPE_MIDIaudio/midi
YS_MIME_TYPE_MJStext/javascript
YS_MIME_TYPE_MMLtext/mathml
YS_MIME_TYPE_MNGvideo/x-mng
YS_MIME_TYPE_MOVvideo/quicktime
YS_MIME_TYPE_MP3audio/mpeg
YS_MIME_TYPE_MP4video/mp4
YS_MIME_TYPE_MPEGvideo/mpeg
YS_MIME_TYPE_MPGvideo/mpeg
YS_MIME_TYPE_MSIapplication/octet-stream
YS_MIME_TYPE_MSMapplication/octet-stream
YS_MIME_TYPE_MSPapplication/octet-stream
YS_MIME_TYPE_OGAaudio/ogg
YS_MIME_TYPE_OGGaudio/ogg
YS_MIME_TYPE_OGVvideo/ogg
YS_MIME_TYPE_OGXapplication/ogg
YS_MIME_TYPE_OPUSaudio/ogg
YS_MIME_TYPE_OTCfont/collection
YS_MIME_TYPE_OTFfont/otf
YS_MIME_TYPE_PDBapplication/x-pilot
YS_MIME_TYPE_PDFapplication/pdf
YS_MIME_TYPE_PEMapplication/x-x509-ca-cert
YS_MIME_TYPE_PLapplication/x-perl
YS_MIME_TYPE_PMapplication/x-perl
YS_MIME_TYPE_PNGimage/png
YS_MIME_TYPE_PPTapplication/vnd.ms-powerpoint
YS_MIME_TYPE_PPTXapplication/vnd.openxmlformats-officedocument.presentationml.presentation;
YS_MIME_TYPE_PRCapplication/x-pilot
YS_MIME_TYPE_PSapplication/postscript
YS_MIME_TYPE_RAaudio/x-realaudio
YS_MIME_TYPE_RARapplication/vnd.rar
YS_MIME_TYPE_RDFapplication/rdf+xml
YS_MIME_TYPE_RPMapplication/x-redhat-package-manager
YS_MIME_TYPE_RSSapplication/rss+xml
YS_MIME_TYPE_RTFapplication/rtf
YS_MIME_TYPE_RUNapplication/x-makeself
YS_MIME_TYPE_SEAapplication/x-sea
YS_MIME_TYPE_SHTMLtext/html
YS_MIME_TYPE_SITapplication/x-stuffit
YS_MIME_TYPE_SPXaudio/ogg
YS_MIME_TYPE_SVGimage/svg+xml
YS_MIME_TYPE_SVGZimage/svg+xml
YS_MIME_TYPE_SWFapplication/x-shockwave-flash
YS_MIME_TYPE_TCLapplication/x-tcl
YS_MIME_TYPE_TIFimage/tiff
YS_MIME_TYPE_TIFFimage/tiff
YS_MIME_TYPE_TKapplication/x-tcl
YS_MIME_TYPE_TSvideo/mp2t
YS_MIME_TYPE_TTCfont/collection
YS_MIME_TYPE_TTFfont/ttf
YS_MIME_TYPE_TTLtext/turtle
YS_MIME_TYPE_TXTtext/plain
YS_MIME_TYPE_UDEBapplication/vnd.debian.binary-package
YS_MIME_TYPE_USDZmodel/vnd.pixar.usd
YS_MIME_TYPE_VTTtext/vtt
YS_MIME_TYPE_WARapplication/java-archive
YS_MIME_TYPE_WASMapplication/wasm
YS_MIME_TYPE_WBMPimage/vnd.wap.wbmp
YS_MIME_TYPE_WEBMvideo/webm
YS_MIME_TYPE_WEBPimage/webp
YS_MIME_TYPE_WMLtext/vnd.wap.wml
YS_MIME_TYPE_WMLCapplication/vnd.wap.wmlc
YS_MIME_TYPE_WMVvideo/x-ms-wmv
YS_MIME_TYPE_WOFFfont/woff
YS_MIME_TYPE_WOFF2font/woff2
YS_MIME_TYPE_XHTapplication/xhtml+xml
YS_MIME_TYPE_XHTMLapplication/xhtml+xml
YS_MIME_TYPE_XLSapplication/vnd.ms-excel
YS_MIME_TYPE_XLSXapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
YS_MIME_TYPE_XMLtext/xml
YS_MIME_TYPE_XPIapplication/x-xpinstall
YS_MIME_TYPE_XSPFapplication/xspf+xml
YS_MIME_TYPE_ZIPapplication/zip
YS_MIME_TYPE_ZSTapplication/zstd

Time Helpers

ys_n_minutes_from_now

c
time_t ys_n_minutes_from_now(unsigned int n)

ys_n_minutes_from_now returns a time_t representing the current time plus n minutes.

ys_n_hours_from_now

c
time_t ys_n_hours_from_now(unsigned int n)

ys_n_hours_from_now returns a time_t representing the current time plus n hours.

ys_n_days_from_now

c
time_t ys_n_days_from_now(unsigned int n)

ys_n_days_from_now returns a time_t representing the current time plus n days.