JUCE 1.37
Just a heads-up. This one had me foxed for a while.
I noticed my client code was pumping lots of extra records into my server-side db, even though i was sure i was submitting only once.
Something like this:
URL u(m_ServerUrl + T("/cgi-bin/getwork.cgi"));
InputStream *i = u.createPostInputStream("function=get_work");
m_Name = i->readNextLine();
m_JobId = i->readNextLine();
m_Data = i->readNextLine().getHexValue64();
m_Key1 = i->readNextLine().getHexValue32();
m_Key2Start = i->readNextLine().getHexValue32();
m_Key2End = i->readNextLine().getHexValue32();
m_Key3 = i->readNextLine().getHexValue32();
The cgi script sends back plaintext, but if the lines are only terminated with “\n” readNextLine() reads the entire content and re-submits the request for each subsequent call! If I make the server send back “\r\n” as a line terminator, everything is hunky-dory.
I’m not sure which is the “correct” way to send back line-endings, but most of the scripts i’ve seen only use “\n”.