Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3699

Verify understanding of URLConnection ReceivingProgressed

$
0
0

Running into an issue with an API I’m consuming and hoping to find reliable way to handle it.
Issue:

  • Request/Response works perfectly when URL & args passed are ‘perfect’, and the response is the record that was requested.
  • If an arg name isn’t perfect (lower-case, typo, etc.) the API doesn’t reply with an error, instead it responds with all records, stopping only when it reaches some unknown max number.

While I can test and ensure I submit only ‘perfect’ requests, there’s always the chance that the publisher could still reply with a ‘dump’ instead of an error.

I’m looking into using some type of byte-limit on a response, to know when it’s a ‘dump’ vs. a legitimate reply. Looking at ReceivingProgressed I see ‘totalBytes’, and was hoping it was a reference to the entire payload, the docs are a little light in this area. A better assumption is that ‘ReceivingProgressed’ will get called as each portion of a response trickles in - which is why I’m posting for advice.

My initial plans are to add up an accumulated ‘totalBytes’ value, and when ContentReceived fires I’d evaluate the total of ‘totalBytes’ to see if it exceeds the reasonable byte count of a proper response.

Any insights and suggestions here are appreciated. Thx!

ReceivingProgressed(bytesReceived As Int64, totalBytes As Int64, newData As String)
ContentReceived(URL As String, HTTPStatus As Integer, content As String)

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 3699

Trending Articles