Re: [racket-users] Safely using port->string where nothing has been written to the port

2017-01-24 Thread Sean Kemplay
Hi David,

Indeed it does!! Thanks for your help.

Sean

On Monday, January 23, 2017 at 7:16:58 PM UTC, David K. Storrs wrote:
> Hi Sean,
> 
> Does (byte-ready?) work for your case?
> 
> https://docs.racket-lang.org/reference/Byte_and_String_Input.html?q=peek#%28def._%28%28quote._~23~25kernel%29._byte-ready~3f%29%29
> 
> 
> 
> On Mon, Jan 23, 2017 at 6:05 AM, Sean Kemplay  wrote:
> Hello,
> 
> 
> 
> I am using the URL library to interact with a REST API.
> 
> 
> 
> One of the Endpoints sends returns no content for a POST request with a 
> status code of 204 (a little unusual however it is an external API so we have 
> to cater to it).
> 
> 
> 
> I can check the status code for 204 and only apply string->port if it isn't a 
> 204 - however I was wondering if there is any check that can be made at the 
> port level that no content will be written - in case we encounter a malformed 
> response which does not send through a body.
> 
> 
> 
> Currently without the checks port->string will hang on a 204 response.
> 
> 
> 
> This would be good to know more generally when dealing with ports as well.
> 
> 
> 
> Kind regards,
> 
> Sean
> 
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> 
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users...@googlegroups.com.
> 
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Safely using port->string where nothing has been written to the port

2017-01-23 Thread David Storrs
Hi Sean,

Does (byte-ready?) work for your case?

https://docs.racket-lang.org/reference/Byte_and_String_Input.html?q=peek#%28def._%28%28quote._~23~25kernel%29._byte-ready~3f%29%29

On Mon, Jan 23, 2017 at 6:05 AM, Sean Kemplay 
wrote:

> Hello,
>
> I am using the URL library to interact with a REST API.
>
> One of the Endpoints sends returns no content for a POST request with a
> status code of 204 (a little unusual however it is an external API so we
> have to cater to it).
>
> I can check the status code for 204 and only apply string->port if it
> isn't a 204 - however I was wondering if there is any check that can be
> made at the port level that no content will be written - in case we
> encounter a malformed response which does not send through a body.
>
> Currently without the checks port->string will hang on a 204 response.
>
> This would be good to know more generally when dealing with ports as well.
>
> Kind regards,
> Sean
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Safely using port->string where nothing has been written to the port

2017-01-23 Thread Sean Kemplay
Hello,

I am using the URL library to interact with a REST API. 

One of the Endpoints sends returns no content for a POST request with a status 
code of 204 (a little unusual however it is an external API so we have to cater 
to it).

I can check the status code for 204 and only apply string->port if it isn't a 
204 - however I was wondering if there is any check that can be made at the 
port level that no content will be written - in case we encounter a malformed 
response which does not send through a body. 

Currently without the checks port->string will hang on a 204 response.

This would be good to know more generally when dealing with ports as well.

Kind regards,
Sean

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.