Page 1 of 1

Creating a url_head routine

Posted: Wed Jun 05, 2024 12:00 pm
by daveslater1964
In the web world there is now a HEAD verb that is similar to GET but returns meta data for an object, not the object.

Is there anyway to incorporate this into the library?

Kind Regards,

Dave

Re: Creating a url_head routine

Posted: Wed Jun 05, 2024 12:44 pm
by jonboy49
Have you tried HTTP_req() ? It is not method specific.

Re: Creating a url_head routine

Posted: Wed Jun 05, 2024 12:48 pm
by daveslater1964
I have seen it and am looking for some examples on how I might use it.

Re: Creating a url_head routine

Posted: Wed Jun 05, 2024 8:25 pm
by Scott Klement
HEAD has existed since at least HTTP 1.0, which was released in 1996.

HTTP_req, HTTP_string, HTTP_stmf are all intended to work with any HTTP method.

here's a simple example (no idea what you're planning to do with HEAD, so not sure how helpful it is)

Code: Select all

**free
ctl-opt dftactgrp(*no) bnddir('HTTPAPI');

 /copy HTTPAPI_H

dcl-s rc int(10);
dcl-s url varchar(1000) inz('https://www.scottklement.com');
dcl-s modified varchar(100);

rc = http_req( 'HEAD': url: *omit);
if rc <> 1;
  http_crash();
endif;

modified = http_header('Last-Modified');
snd-msg 'Page last modified:' + modified;

*inlr = *on;