19
Root
4y

This stupid crap is pissing me off.

I write a quick blob of code that performs an http request with custom headers and writes the response to a file. easy squeezy. Everything works.

I abstract it into a class and add request building and stages (enjoayble!), and have one method make the response, read its body, and write to a file. I literally copy/pasted most of my existing code into the method and indented it. The only changes were updating var names to instance vars.

But now? It's complaining something is trying to read the request body twice, and it's throwing a fit. What? How? You were just working!

asfklasjdf;l

Comments
  • 3
    -Over optimization is the root of all evil

    -Don't fix what isn't broken

    Sounds like this though haven't gone thru it yet...

    https://github.com/EnterpriseQualit...
  • 5
    @donuts ... I'm building a wrapper for an external service. Kinda need the abstraction.
  • 8
    @Root maybe debug it one more time and then sleep on it. And then in the morning you get the "it's so obvious... How'd I miss that"
  • 0
    Did you leave any logging function in that dumps it on the screen too?
  • 3
    The response is most likely a stream buffer and you must reset the reader pointer to 0 before re-reading it.
  • 4
    I never did figure out why the behavior changed. It’s odd and makes no sense.

    So instead, I added a check and now only read the body if it hasn’t already been read and buffered. It’s also odd, but it works.

    @ReverendLovejoy is probably right, but the strange part is why it started behaving that way.
Add Comment