[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HTTPAPI Examples: What if I don't want to save what I get to a file?



Yes, that's exactly right.  You can pass an invalid FD to the raw 
routines if the callback routine doesn't need to use it.

Basically, HTTPAPI will call your callback routine in place of the 
write() API (from the IBM supplied IFS APIs).  HTTPAPI doesn't care what 
the value in the FD parameter is -- it's just a number that HTTPAPI 
passes on to the callback routine.   In the case of the IFS write() API, 
it tells OS/400 which stream file to write to.  But if you're writing 
your own callback, you can just pass zero and ignore it in the callback 
routine.

The only caveat:   HTTPAPI will call your callback as soon as any 
network data comes in over the wire.  It does not wait until the buffer 
(the data passed in the 2nd parameter) is full, and it doesn't wait 
until the entire document has been received.  As soon as there's any 
data to receive, it calls your callback immediately and passes that 
data.   Then, when your routine returns back to HTTPAPI, it waits for 
more data to arrive, then calls your routine again, etc, in a loop til 
the whole document is finished.

That means that if you want the entire doc to be received into your 
program for processing, you have to accumulate it in your callback, and 
wait to process it until the http_url_get_raw() or http_url_post_raw() 
routine has finished running. There's an example of this in EXAMPLE5.



James Lampert wrote:
> James Lampert wrote:
>> Given that Examples 1, 9, and 11 get "SOCK_TUTORIAL.PDF" from Scott's 
>> web site, and stick it into an IFS file, with 9 using "http_url_get_raw" 
>> and passing it a callback routine:
>>
>> What if I want to process what I get back, instead of just pouring it 
>> into an IFS file? What example should I be looking at?
>>
> Would I be able to use the "get_raw" version, and just not pass a 
> legitimate FD if the callback isn't going to be doing anything with it?
> 

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------