Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Redundant status code emits? #14
I noticed the HTTP status code gets applied with every individual
But headers get emitted before the status line:
And the status line gets emitted last, with the status code:
Any reason why it isn't enough to just apply the status code last with
Note that this isn't an issue with the code, merely a bit of a comprehension difficulty.
I'm sure it isn't harmful to apply the status code repeatedly - but unless it's meaningful, it's probably confusing more than it is helpful to a person reading the code?
My question is, is it really necessary to pass the status-code for every individual header-line?
From the rest of the comments, I expect the answer is no?
If I understand correctly, you're defensively setting the status code in both places, in case somebody were to think it's a good idea to change the call order in the other function someday?
(This isn't meant as a criticism or anything - I am genuinely trying to understand how this works.)
@mindplay-dk you're correct when you say that only changing the order would address the issue. I opted to go with the same approach as
I've tried to explain that in the commit messages but reading them now I realise that the explanation could have been better. Sorry about the confusion
@lcobucci thanks, no problem :-)
(I personally wouldn't have done it if it wasn't necessary - most likely, I would have chosen to simply fold the status line and header emits into a single method, so that the order can't be accidentally changed. In my opinion, doing unnecessary things only raises questions or creates confusion. Just my opinion.)