Creating a url_head routine

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
daveslater1964
Posts: 4
Joined: Tue Feb 06, 2024 3:39 pm

Creating a url_head routine

Post 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
jonboy49
Posts: 244
Joined: Wed Jul 28, 2021 8:18 pm

Re: Creating a url_head routine

Post by jonboy49 »

Have you tried HTTP_req() ? It is not method specific.
daveslater1964
Posts: 4
Joined: Tue Feb 06, 2024 3:39 pm

Re: Creating a url_head routine

Post by daveslater1964 »

I have seen it and am looking for some examples on how I might use it.
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: Creating a url_head routine

Post 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;
Post Reply