.. index:: single: http_body_codec_protocol
.. _http_body_codec_protocol/0:

.. rst-class:: right

**protocol**

``http_body_codec_protocol``
============================

Protocol for portable HTTP body codecs.

| **Availability:** 
|    ``logtalk_load(http_core(loader))``

| **Author:** Paulo Moura
| **Version:** 1:0:0
| **Date:** 2026-06-26

| **Compilation flags:**
|    ``static``


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: media_types/1
.. _http_body_codec_protocol/0::media_types/1:

``media_types/1``
^^^^^^^^^^^^^^^^^

Returns the media types supported by this body codec.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``media_types(MediaTypes)``
| **Mode and number of proofs:**
|    ``media_types(-list(atom))`` - ``one``


------------

.. index:: encode_body/4
.. _http_body_codec_protocol/0::encode_body/4:

``encode_body/4``
^^^^^^^^^^^^^^^^^

Encodes a semantic payload term for the given media type and options into a normalized HTTP body term.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``encode_body(MediaType,Payload,Options,Body)``
| **Mode and number of proofs:**
|    ``encode_body(+atom,++term,+list(compound),-compound)`` - ``one_or_error``

| **Exceptions:**
|    ``MediaType`` is not a valid HTTP media type atom:
|        ``domain_error(http_media_type,MediaType)``
|    ``Payload`` is not valid for ``MediaType``:
|        ``domain_error(http_body_payload,Payload)``
|    ``Options`` is not a valid HTTP body options list:
|        ``domain_error(http_body_options,Options)``
|    ``Body`` is not a valid normalized HTTP body term:
|        ``domain_error(http_body,Body)``


------------

.. index:: decode_body/4
.. _http_body_codec_protocol/0::decode_body/4:

``decode_body/4``
^^^^^^^^^^^^^^^^^

Decodes a normalized HTTP body term for the given media type and options into a semantic payload term.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``decode_body(MediaType,Body,Options,Payload)``
| **Mode and number of proofs:**
|    ``decode_body(+atom,++compound,+list(compound),-term)`` - ``one_or_error``

| **Exceptions:**
|    ``MediaType`` is not a valid HTTP media type atom:
|        ``domain_error(http_media_type,MediaType)``
|    ``Body`` is not a valid normalized HTTP body term:
|        ``domain_error(http_body,Body)``
|    ``Options`` is not a valid HTTP body options list:
|        ``domain_error(http_body_options,Options)``
|    ``Payload`` cannot be decoded from ``Body`` for ``MediaType``:
|        ``domain_error(http_body_payload,Payload)``


------------

Protected predicates
--------------------

(none)

Private predicates
------------------

(none)

Operators
---------

(none)

