1. Eunet - eunet_get_url()

Hello, eunet_get_url function doesn't work with MAC addresses gibent on the URL line (GET). I fond url decoding quite complicated. Here is a proposal for a new eunet_get_url function. It has been tested with 216 URL combinations.

global function eunet_get_url(sequence url) 
 
  sequence node, hostname, protocol, port, file, inet_addr 
  sequence data 
  atom cpos 
  object addrinfo 
 
  -- protocol 
 
  cpos = match("://",url) 
  if cpos > 0 then 
    protocol = url[1..cpos-1] 
    url = url[cpos+3..$] 
  else 
    protocol = "http"  -- assumed default 
  end if 
 
  -- hostname, port 
 
  cpos = find('/',url) 
  if cpos > 0 then 
    node = url[1..cpos-1] 
    file = url[cpos+1..$] 
  else 
    cpos = find('?',url) 
    if cpos > 0 then 
      node = url[1..cpos-1] 
      file = url[cpos+1..$] 
    else 
      node = url 
      file = "" 
    end if 
  end if 
  cpos = match(":",node) 
  if cpos > 0 then 
    hostname = node[1..cpos-1] 
    port = node[cpos+1..$] 
  else 
    hostname = node 
    port = "" 
  end if 
 
  if length(file)>0 and file[1]='/' then file = file[2..length(file)] end if 
  addrinfo = eunet_getaddrinfo(node,protocol,0) 
  if atom(addrinfo) or length(addrinfo)<1 or length(addrinfo[1])<5 then 
    -- attempt to use deprecated methods 
    return {} -- failed 
  else 
    inet_addr = addrinfo[1][5] 
  end if 
  data = {} 
  if compare(lower(protocol),"http")=0 then 
    data = eunet_get_http(inet_addr,hostname,file) 
  end if 
 
  return data 
 
end function 

If needed, I have a version with an additional params variable (what follows "?").

Regards

Jean-Marc

(Edit: Added <eucode> tags for formatting. -euphoric)

new topic     » topic index » view message » categorize

2. Re: Eunet - eunet_get_url()

Thank you for the revised function. I'll have to admit that I've never tried to reference a MAC address directly, and with IPv6 only really working in Linux, never included that functionality in the library.

I'll admit I'm well overdue for publishing an update to the library. I can't promise when I'll get it out, but this will be included when I do (with your permission, of course).

new topic     » goto parent     » topic index » view message » categorize

3. Re: Eunet - eunet_get_url()

That's why I sent it of course.

I'm glad to be helpful.

regards

Jean-Marc

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu