emiago / sipgo

SIP library for writing fast SIP services in GO
BSD 2-Clause "Simplified" License
546 stars 72 forks source link

Allow to serialize headers in compact form #93

Open darkrift opened 4 months ago

darkrift commented 4 months ago

The request is to support serializing a SIP message with headers in their compact forms.

Potentially also storing in which form the header was parsed in to be transparent when receiving a message, altering it, and forward them back in their initial received form.

emiago commented 4 months ago

it is called lazy parsing. Altering parser default headers parsing, should bring you to this level, but I could agree there could be some global level of control, to still preserve default behavior.

For now you can try customizing parser passed on UA.

Check option WithHeadersParsers

Making this empty, basically removes any header value parsing and form of K:V will be preserved as received. Calling Via() or From or any shortcut on request/response triggers lazy parsing on header value, but should not alter original form.

On sending there is some work You can build all headers manually before passing client.TransactionRequest or client.Do

Client should not override if all necessary headers are present. Via,From,To. etc

Of course probably there is some functionally where we replace headers with parsed so having some globals to alter this could be better way.

Leaving open