From WikiChip
Editing mirc/identifiers/$urlget

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 1: Line 1:
{{mirc title|$urlget identifier}}'''$urlget''' sends a HEAD/GET/POST/PUT/PATCH/DELETE to an http server. Returns an ID. Can also be used to get infos about current running $urlget.
+
{{mirc title|$urlget identifier}}'''$urlget''' sends a GET/POST to an http server.
  
 
== Synopsis ==
 
== Synopsis ==
<source lang="mIRC">
+
<pre>$urlget()</pre>
$urlget(url,hgpuadfbtike,<target>,<alias>,[&headers],[&body])
 
$urlget(N/ID,cr)
 
$urlget(N/ID)[.prop]
 
</source>
 
  
 
== Parameters ==
 
== Parameters ==
 
* '''url''' - the url to access, must be prefixed with http:// or https:// (maximum url characters are <b>2000</b>)
 
* '''hgpuadfbrtice''' - switches to indicate how to proceed:
 
** '''hgpuad''' - '''h''' for HEAD, '''g''' for GET, '''p''' for POST, '''u''' for PUT, '''a''' for PATCH, '''d''' for DELETE
 
** '''fb''' - '''f''' to output the answer (without the responses headers) to a file, '''b''' to ouput to a binvar
 
** '''r''' - resumes the processing,
 
** '''t''' - uses .part file if necessary
 
** '''i''' - ignores SSL errors
 
** '''c''' - cancel the processing
 
** '''k''' - prevent redirection
 
** '''e''' - save failed download reply to the &binvar/file
 
* '''target''' - the output: the filename if you used '''f''', or a &binvar for '''b'''
 
* '''alias''' - the name of the alias that is called at the end, this alias is called as a command with one parameter passed to it: the ID
 
* '''headers''' - optional, a &binvar containing the headers to be sent, separated by $crlf
 
* '''body''' - optional, a &binvar containing the data to be sent when you are POSTing
 
* '''ID/N''' - the Nth urlget or the urlget referenced by the ID
 
  
 
== Properties ==
 
== Properties ==
 
* '''.url''' - returns the url used
 
* '''.redirect''' - returns the value of the location header if available
 
* '''.method''' - returns the method used (GET/POST)
 
* '''.type''' - returns the type of output, (binvar/file)
 
* '''.target''' - returns the value of target (name of the binvar or filename)
 
* '''.alias''' - returns the name of the alias used
 
* '''.id''' - returns the ID.
 
* '''.state''' - returns the state (ok, connect, download, fail)
 
* '''.size''' - returns the value of the content-lenght header
 
* '''.resume''' - returns 0 or 1 depending on if you are resumed/paused?
 
* '''.rcvd''' - returns the number of bytes received after the header, could be different from .size after a failed download.
 
* '''.time''' - returns the time taken to complete the processing, in millisecond
 
* '''.reply''' - returns the response headers
 
  
 
== Example ==
 
== Example ==
Usage: /download https://www.mirc.com/versions.txt
 
<source lang="mIRC">
 
alias download {
 
  if (!$1) { return }
 
 
  if ($1 isnum) {
 
    if ($urlget($1).state == fail) { echo 4 -at Error: Connection issues! | return }
 
 
    .run notepad.exe $qt($urlget($1).target)
 
  }
 
  else {
 
    var %file = source.txt
 
 
    write -c $qt(%file)
 
 
    return $urlget($1,gfi,%file,download)
 
  }
 
}</source>
 
 
----------
 
 
Type /urlget.test
 
 
<source lang="mIRC">; > POST / HTTP/1.1
 
<source lang="mIRC">; > POST / HTTP/1.1
 
; > Accept: */*
 
; > Accept: */*
Line 78: Line 22:
 
; < Connection: close
 
; < Connection: close
 
; < Content-Length: 5
 
; < Content-Length: 5
; < hello
+
; <  
 +
; hello
 
; url      http://localhost/
 
; url      http://localhost/
 
; redirect http://localhost/
 
; redirect http://localhost/
Line 91: Line 36:
 
; rcvd    5
 
; rcvd    5
 
; time    125
 
; time    125
; reply    HTTP/1.1 200 OKConnection: closeContent-Length: 5
+
; reply    HTTP/1.1 200 OK
 +
; Connection: close
 +
; Content-Length: 5
 +
;
 +
;
 
; response hello
 
; response hello
 
   
 
   
Line 181: Line 130:
 
   sockwrite -n %sockname Content-Length: $len(%data)
 
   sockwrite -n %sockname Content-Length: $len(%data)
 
   sockwrite -n %sockname $+($crlf,%data)
 
   sockwrite -n %sockname $+($crlf,%data)
}
+
}</source>
 
 
</source>
 
 
 
cancelling and resuming
 
<source lang="mIRC">
 
;cancel the first $urlget request currently running
 
$urlget(1,c)
 
 
 
 
 
;resume the request identified by the id <id>
 
$urlget(<id>,r)
 
</source>
 
  
 
== Compatibility ==
 
== Compatibility ==

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)