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

fix miscalculation of rlen #3

Closed
wants to merge 1 commit into from

Conversation

feihu-stripe
Copy link

No description provided.

M(metaend, "EN\r\n", MCMC_RESP_META, MCMC_CODE_END, MCMC_OK, 0)
M(metaexists, "EX\r\n", MCMC_RESP_META, MCMC_CODE_EXISTS, MCMC_OK, 0)
M(metaok, "HD\r\n", MCMC_RESP_META, MCMC_CODE_OK, MCMC_OK, 0)
M(metaok2, "HD O123 C123\r\n", MCMC_RESP_META, MCMC_CODE_OK, MCMC_OK, 11)
Copy link
Author

Choose a reason for hiding this comment

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

new test

M(metanotfound, "NF\r\n", MCMC_RESP_META, MCMC_CODE_NOT_FOUND, MCMC_OK, 0)
M(metanotstored, "NS\r\n", MCMC_RESP_META, MCMC_CODE_NOT_STORED, MCMC_OK, 0)
M(metavalue, "VA 2 t\r\nhi\r\n", MCMC_RESP_META, MCMC_CODE_OK, MCMC_OK, 3) // FIXME: does this make sense?
M(metavalue2, "VA 2\r\nho\r\n", MCMC_RESP_META, MCMC_CODE_OK, MCMC_OK, 0)
Copy link
Author

Choose a reason for hiding this comment

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

this is 0 not 2 due to the else

            if (more) {
                r->rline = cur+1; // eat the space.
                r->rlen = l-1;
            } else {
                r->rline = NULL;
                r->rlen = 0;
            }

@dormando
Copy link
Owner

So I ran into this (the rline being wrong with meta) with mcshredder this week. For meta the rline was supposed to be where the flags start, but I'm not sure that actually made sense anymore.

So I need to make a decision on how it should be properly calculated, I think.

@feihu-stripe
Copy link
Author

So I need to make a decision on how it should be properly calculated, I think.

Agreed, why can't just return the entire result line, which is how I understand
"resp:line(): for use with meta, returns the full response header line." from the wiki.

@dormando
Copy link
Owner

It probably just needs to be two functions; one for getting the meta flags line and one for "full response line". I'm not sure I have the brainpower to make this decision today though.

The problem is mcmc is a core client library, so "where do the meta flags start?" is a legitimate question for a client builder.

@feihu-stripe
Copy link
Author

Sounds good. We don't use line() in our Lua, so take you time.

@dormando
Copy link
Owner

cripes. took more than a year to circle back to this. what a nightmare.

I've got this fixed a different way the branch that I'm working on, so I'll close this out. I refactored to remove l entirely and rely on cur. also fixes some bugs with leading spaces and lines with missing \r.

@dormando dormando closed this Jun 18, 2024
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.

None yet

2 participants