Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial bodies #480

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Partial bodies #480

wants to merge 5 commits into from

Conversation

pmccarren
Copy link
Contributor

Added the ability to fetch partial bodies. Ex: 'TEXT<0.2048>'

@mscdex
Copy link
Owner

mscdex commented Jun 17, 2015

This isn't very feasible unfortunately because of how (from what I've seen and how I interpret the RFC) IMAP servers return partial bodies. Basically it boils down to there being no real way to match up partial bodies that start from the same starting offset because the servers only return the starting offset for partial bodies.

@pmccarren
Copy link
Contributor Author

I use it for the use cause when someone has a huge, literally over 50MB, inline attachment. It allows me to not receive the full body from the server, saving precious resources :)

@mscdex
Copy link
Owner

mscdex commented Jun 17, 2015

I agree it can be useful. The only way I see this working generally though is we would have to disallow fetching multiple partial bodies that start at the same offset.

@@ -45,7 +45,8 @@ var MAX_INT = 9007199254740992,
RE_BACKSLASH = /\\/g,
RE_DBLQUOTE = /"/g,
RE_ESCAPE = /\\\\/g,
RE_INTEGER = /^\d+$/;
RE_INTEGER = /^\d+$/,
RE_PARTIAL_BODY = /^(TEXT)(<[0-9]+\.[0-9]+>)$/;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that partial fetches are limited strictly to TEXT.

@pmccarren
Copy link
Contributor Author

@mscdex Good idea with allowing all body types.

Now I'm running into an issue where the parser has trouble parsing the bodies being returned. Would you be willing to help me get this resolved?

@@ -12,7 +12,7 @@ var CH_LF = 10,
EMPTY_READCB = function(n) {},
RE_INTEGER = /^\d+$/,
RE_PRECEDING = /^(?:(?:\*|A\d+) )|\+ ?/,
RE_BODYLITERAL = /BODY\[(.*)\] \{(\d+)\}$/i,
RE_BODYLITERAL = /BODY\[(.*)\](<[0-9]+>)* \{(\d+)\}$/i,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The * operator in this change isn't correct I think. There is only ever one set of < and >. It should instead be a ? to make it optional.

@mscdex
Copy link
Owner

mscdex commented Jul 21, 2015

@pmccarren What problem is that?

@kael
Copy link

kael commented Nov 11, 2019

+1 on adding partial BODY FETCH response regex pattern.

This works:

RE_BODYLITERAL = /BODY\[(.*)\](?:<(\d+)>)? \{(\d+)\}/i;

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.

3 participants