Skip to content

Strip a leading header from a byte payload

Strip a leading transport header so a payload starts at its own signature, triggered when caller has a document payload prefixed with transport bytes and needs it to start at its own signature (e.g. "%PDF-").

Field Value
Operation ID OP-024
Trigger Caller has a document payload prefixed with transport bytes and needs it to start at its own signature (e.g. "%PDF-")
Inputs input, searchFor, maxBytesToSearch
Outputs Trimmed Byte[], out bool found
Primary components ByteExtensions.StripHeader(this Byte[] input, string searchFor, out bool found, int maxBytesToSearch = 100)
Entry point Common/SAIF.Common/Extensions/ByteExtensions.cs

Steps

  1. Call OP-023 to find the signature, capping the scan at maxBytesToSearch (default 100 bytes). (BR-053, BR-055)
  2. Initialise found = false.
  3. If the signature was found at a position greater than zero, set found = true and return the payload skipped forward to that position. (BR-056)
  4. Otherwise — not found, or found at index 0 — return the original array unchanged with found = false. (BR-056)

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start(["Payload prefixed with<br>transport bytes"]) --> S1["Find signature via OP-023<br>(cap scan at maxBytesToSearch,<br>default 100 bytes)"]
    S1 --> S2["Initialise found = false"]
    S2 --> D1{"Signature found at position<br>greater than zero?"}
    D1 -->|Yes| S3["Set found = true; return<br>payload skipped forward<br>to that position"]
    D1 -->|No| S4["Return original array<br>unchanged with found = false"]
    S3 --> End(["Trimmed payload returned"])
    S4 --> End

Sources

  • Common/SAIF.Common/Extensions/ByteExtensions.cs