Skip to content

Add BodyRaw() method to retrieve raw article body without decoding#64

Open
asdffer wants to merge 1 commit intojavi11:mainfrom
asdffer:feature/raw-body
Open

Add BodyRaw() method to retrieve raw article body without decoding#64
asdffer wants to merge 1 commit intojavi11:mainfrom
asdffer:feature/raw-body

Conversation

@asdffer
Copy link
Copy Markdown

@asdffer asdffer commented Apr 15, 2026

Add BodyRaw() method to retrieve raw article body without decoding

Description

Adds a new BodyRaw() method to the Client API that retrieves article bodies without applying yEnc or UU decoding. This is useful for cases where the raw encoded content needs to be inspected or processed directly without automatic decoding.

Changes

  • New public method BodyRaw(): Retrieves raw article body bytes without decoding
  • RawMode flag: Added to Request and NNTPResponse structs to skip the decoding pipeline
  • Updated decoder: Modified the decode() function to pass through raw bytes when RawMode is enabled, while still handling NNTP protocol details like dot-stuffing

Implementation Details

  • When RawMode=true, the decoder skips yEnc and UU decoding logic entirely
  • Raw bytes are streamed directly to the response buffer
  • NNTP protocol handling (end markers, dot-stuffing) is preserved
  • Integrates seamlessly with existing provider retry logic via sendRaw() helper

Usage Example

body, err := client.BodyRaw(ctx, messageID)
if err != nil {
    log.Fatal(err)
}
// body.Bytes contains raw, undecoded article content

Testing

  • No breaking changes to existing API
  • Existing Body/BodyStream/BodyAsync methods unchanged
  • RawMode is opt-in via the new BodyRaw() method

@javi11
Copy link
Copy Markdown
Owner

javi11 commented Apr 15, 2026

Can you instead just reuse everything that is there just add the new method and pass a variable to prevent the yenc decoder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants