* http response: can't read body
@ 2017-10-22 22:25 Matt Wette
2017-10-23 9:36 ` Chris Vine
0 siblings, 1 reply; 4+ messages in thread
From: Matt Wette @ 2017-10-22 22:25 UTC (permalink / raw)
To: Guile User Mailing List
I'm using Guile 2.2.2 web api and I can't get the body.
I'm getting a response from (http-get <query>).
The (response-code resp) is 200.
The value I get back from (response-body-port resp) says #t for port? and input-port?
But if I try to read-char on the port I get:
ERROR: In procedure get-bytevector-n!:
ERROR: In procedure get-bytevector-n!: Wrong type argument in position 1 (expecting open input port): #<closed: string 106c24b60>
I get the same error if I use read-response-body.
What am I doing wrong?
Matt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: http response: can't read body
2017-10-22 22:25 http response: can't read body Matt Wette
@ 2017-10-23 9:36 ` Chris Vine
2017-10-23 12:29 ` Matt Wette
0 siblings, 1 reply; 4+ messages in thread
From: Chris Vine @ 2017-10-23 9:36 UTC (permalink / raw)
To: guile-user
On Sun, 22 Oct 2017 15:25:54 -0700
Matt Wette <matt.wette@gmail.com> wrote:
> I'm using Guile 2.2.2 web api and I can't get the body.
>
> I'm getting a response from (http-get <query>).
> The (response-code resp) is 200.
> The value I get back from (response-body-port resp) says #t for port?
> and input-port?
>
> But if I try to read-char on the port I get:
> ERROR: In procedure get-bytevector-n!:
> ERROR: In procedure get-bytevector-n!: Wrong type argument in
> position 1 (expecting open input port): #<closed: string 106c24b60>
>
> I get the same error if I use read-response-body.
>
> What am I doing wrong?
>
> Matt
I have only used http-get in non-streaming mode, but if you are
streaming with http-get as I read the documentation you do not use
response-body-port - that is for response objects returned by
read-response: instead you read the port returned by http-get as its
second value .
Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: http response: can't read body
2017-10-23 9:36 ` Chris Vine
@ 2017-10-23 12:29 ` Matt Wette
2017-10-23 12:48 ` Chris Vine
0 siblings, 1 reply; 4+ messages in thread
From: Matt Wette @ 2017-10-23 12:29 UTC (permalink / raw)
To: Chris Vine; +Cc: guile-user
> On Oct 23, 2017, at 2:36 AM, Chris Vine <vine35792468@gmail.com> wrote:
>
> On Sun, 22 Oct 2017 15:25:54 -0700
> Matt Wette <matt.wette@gmail.com> wrote:
>> I'm using Guile 2.2.2 web api and I can't get the body.
>>
>> I'm getting a response from (http-get <query>).
>> The (response-code resp) is 200.
>> The value I get back from (response-body-port resp) says #t for port?
>> and input-port?
>>
>> But if I try to read-char on the port I get:
>> ERROR: In procedure get-bytevector-n!:
>> ERROR: In procedure get-bytevector-n!: Wrong type argument in
>> position 1 (expecting open input port): #<closed: string 106c24b60>
>>
>> I get the same error if I use read-response-body.
>>
>> What am I doing wrong?
>>
>> Matt
>
> I have only used http-get in non-streaming mode, but if you are
> streaming with http-get as I read the documentation you do not use
> response-body-port - that is for response objects returned by
> read-response: instead you read the port returned by http-get as its
> second value .
>
> Chris
>
Thanks. Second value is a bytevector. -- Matt
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: http response: can't read body
2017-10-23 12:29 ` Matt Wette
@ 2017-10-23 12:48 ` Chris Vine
0 siblings, 0 replies; 4+ messages in thread
From: Chris Vine @ 2017-10-23 12:48 UTC (permalink / raw)
To: guile-user
On Mon, 23 Oct 2017 05:29:54 -0700
Matt Wette <matt.wette@gmail.com> wrote:
> > On Oct 23, 2017, at 2:36 AM, Chris Vine <vine35792468@gmail.com>
> > wrote:
> >
> > On Sun, 22 Oct 2017 15:25:54 -0700
> > Matt Wette <matt.wette@gmail.com> wrote:
> >> I'm using Guile 2.2.2 web api and I can't get the body.
> >>
> >> I'm getting a response from (http-get <query>).
> >> The (response-code resp) is 200.
> >> The value I get back from (response-body-port resp) says #t for
> >> port? and input-port?
> >>
> >> But if I try to read-char on the port I get:
> >> ERROR: In procedure get-bytevector-n!:
> >> ERROR: In procedure get-bytevector-n!: Wrong type argument in
> >> position 1 (expecting open input port): #<closed: string 106c24b60>
> >>
> >> I get the same error if I use read-response-body.
> >>
> >> What am I doing wrong?
> >>
> >> Matt
> >
> > I have only used http-get in non-streaming mode, but if you are
> > streaming with http-get as I read the documentation you do not use
> > response-body-port - that is for response objects returned by
> > read-response: instead you read the port returned by http-get as its
> > second value .
> >
> > Chris
> >
>
> Thanks. Second value is a bytevector. -- Matt
OK, then you are not doing streaming. For a non-streaming call, it's a
string if decode-body? is true (the default) and the content type is
textual, otherwise a bytevector. If you want to ensure you get a
bytevector so as to do any conversion yourself, set decode-body? to
false.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-23 12:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-22 22:25 http response: can't read body Matt Wette
2017-10-23 9:36 ` Chris Vine
2017-10-23 12:29 ` Matt Wette
2017-10-23 12:48 ` Chris Vine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).