21
Root
3y

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"
  • 7
    Make sure your old code isn't running somewhere. I don't know if this could be an issue, but sometimes I do something and now I get 2 things doing what only one should be doing. I probably don't understand the problem enough to provide a lucid response though.
  • 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.
  • 5
    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.
  • 1
    @Root I found in QML code for Qt that I could actually write code that executed on an object before it "fully" existed in the context. This made for some interesting code that checked for the existence of the object it was being executed on before it existed to be executed on. So I ended up with some stupid check to detect this situation.

    My guess is I was doing something I probably shouldn't have been doing in the first place.
Add Comment