Chapter 6, Test checking the data sent

why are doing this guard this statement, because what I understand is that the urlRequest already setted from the blabber model so why are we doing that again. I tried to remove this but the test failed so I don’t quite understand. @icanzilb

Hi @omarelsayed , could your provide the section in the chapter where this is at? I’d like to see more context. Thanks!

Page 136, the top code snippet. @robertomachorro

Thanks, found it. Please note that I’m not the author, however, I’m trying to help out.

The guard is there to convert an optional httpBodyStream to a non-optional of type InputStream, this will allow it to be used to extract the data. Click on the properties/types above to go to the Apple Docs.

As you well noted, this shouldn’t fail ever, as that value is already set. And that is why the author has the message “Unexpected …”, because we never expect this to fail. If you don’t do the optional conversion, then the types won’t match when assigning to httpBody.

Hope this helps.

1 Like

But why we are reading it from the httpBodyStream why aren’t we reading it from httpBody

That’s a completely different question from what I understood your original post to be.
Unfortunately, I can’t help you with what the author intended in that case and will let the author answer when they can. I’ll rephrase the question to:

Why are we taking the data from request.httpBodyStream and storing it back into request.httpBody?

1 Like