Early termination of result set processing

With a custom SQL query that I have written in Tableau I noticed that the foreach loop in driver.d SQLExecuteImpl function, which traverses the result set of the query, terminates early and prevents the actual result to be returned to the application when the result data is received in the last batch retrieved from the server. The foreach construct calls the statement client's empty(), front(), and popfront() functions in order as expected, but the empty() function returns true before the last result (that contains the actual result of the query) is retrieved & processed with the front() call. 
Thanks Andrei. I updated the code with your proposal as it is functionally equivalent with an additional assert statement. The reason I didn't use an assertion initially was http get call also has an assertion that was failing for an empty url.