Advertisement
SReject

mirc http client mockup

Jan 18th, 2020
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.12 KB | None | 0 0
  1. mSL based HTTP client aimed at simplifying HTTP requests while being
  2. more robust than $urlget
  3.  
  4. Planned supported features:
  5. Cookie store
  6. Convienanace logic for making URL-Encoded and Multipart requests
  7. Decides when to use one or the other without user defined logic
  8. Formats the request appropriately
  9. Sets default headers such as Content-Length
  10. Convienanace alias of deducing mime-types
  11. Streaming request data from file
  12. Base client can be extended via /HTTP Takeover
  13. Response Compression: gzip, deflate
  14. Chunked response data
  15. Following redirects with user-specified limits
  16. Streaming response body to file
  17.  
  18.  
  19.  
  20. Note about redirects:
  21. This script defaults to using HTTP Keep-Alive for purposes of following
  22. redirects to the same site without having to establish a new connection.
  23.  
  24. Though this is an attempt to optimize the script its not always guaranteed to
  25. work
  26. - The server may not support Keep Alive
  27. - A redirect may not point to the same domain
  28. In such cases a new connection will be used
  29.  
  30. If you perfer a new connection be used with each redirect use
  31. /HTTP Header @name Connection close
  32.  
  33.  
  34.  
  35. /HTTP Open -cimNrNsw @name [@method] @url [@file]
  36. Creates an HTTP Client instance
  37.  
  38. -c
  39. Indicates the request should use a cookie store when following redirects
  40.  
  41.  
  42. -i
  43. Note: AFAIK this is not currently possible as mIRC does not allow ssl certificate errors to be ignored without user input
  44. Indicates SSL certificate errors should be ignored
  45.  
  46. -m
  47. Indicates @method has been specified
  48.  
  49. -rN
  50. Indicates the max number of redirects to follow
  51. If omitted all redirects will be followed
  52. if N is 0, no redirects will be followed
  53.  
  54. -RN
  55. Indicates the max number of circular redirects to follow
  56. If omitted circular redirects will be followed once
  57. If N is 0, no circular redirects will be followed
  58.  
  59. -s
  60. Secret; do not use until documented
  61.  
  62. -w
  63. Wait for /HTTP Fetch to be called to begin the request
  64.  
  65. @name
  66. Name used to reference the HTTP Client instance
  67. Must not be in use by another existing HTTP Client instance
  68. Must not contain spaces, a dash(-) or a colon(:)
  69.  
  70. @method - Switch dependent(-m)
  71. The HTTP request method to use
  72. Defaults to GET
  73.  
  74. @url
  75. The URL to request
  76.  
  77. @file - Optional
  78. The output file to stream the response body in to
  79. If the server uses compression, the file will not be usable until the response has completed
  80.  
  81.  
  82.  
  83. /HTTP Header -a @name @header @value
  84. Stores a request header to be sent with the request
  85.  
  86. -a
  87. Indicates the header should be appended to the list
  88. If not specified and the same header is set multiple times, the previous value will be overwrote
  89.  
  90. @name
  91. HTTP client instance
  92.  
  93. @header
  94. Request header name to set
  95.  
  96. @value
  97. Value for the header
  98.  
  99. Default Headers:
  100. Host: <host>
  101. Accept-Encoding: gzip, deflate
  102. Cache-Control: no-cache
  103. User-Agent: mIRCHttpClient/1.0 (Win NT $os)
  104.  
  105. If /HTTP Form is used the following additional headers are set:
  106. Content-Type
  107. Content-Length
  108.  
  109.  
  110.  
  111. /HTTP Cookie -bo @name @cookie @value [@options]
  112. Stores an initial cookie value
  113. Only applicable if the instance was created with the -c switch
  114.  
  115. -b
  116. Indicates @value is a bvar
  117.  
  118. -o
  119. Forces the cookie to be overwrote even if the expiration is before the currently stored one
  120. This switch is unneeded if an expiration for the cookie is not set in @options
  121.  
  122. @name
  123. HTTP client instance
  124.  
  125. @cookie
  126. The cookie name to store
  127.  
  128. @value
  129. The value of the cookie
  130.  
  131. @options - Optional
  132. Options related to the cookie
  133. Format of these options is a semi-colon(;) delimited list of key=value pairs
  134. Example: SameSite=Strict; Expires=Wed, 21 Oct 2015 07:28:00 GMT; HttpOnly; Secure; Path=/
  135.  
  136. If not specified the cookie will default to using:
  137. Domain=<url_domain>
  138. Path=/
  139. SameSite=None
  140.  
  141.  
  142.  
  143. /HTTP Form -bfFh @name [@mime] @key @value
  144. Prepares a new segment of data to send
  145. The script will decide to use either URL-encoded query string or Multipart when building the data to send
  146. The script will automatically set the Content-Type and Content-Length headers; attempts to override them will be ignored
  147.  
  148. -b
  149. Indicates @value is a bvar that should be URL encoded
  150.  
  151. -B
  152. Indicates @value is a bvar that should be treated as a file
  153.  
  154. -f
  155. Indicates @value is a file to be read into memory
  156.  
  157. -F
  158. Indicates @value is a file that should be streamed from the harddisk
  159.  
  160. -h
  161. Indicates a header for the last segment added is to be set
  162. Forces multipart over url-encoding
  163.  
  164. @name
  165. HTTP client instance
  166.  
  167. @mime - Switch dependent(-B, -f, -F)
  168. Indicates the mime type for the file being added
  169.  
  170. @key
  171. The name of the form-value or header
  172.  
  173. @value
  174. The value for the key
  175.  
  176.  
  177.  
  178. /HTTP Fetch -bdfF @name [@source]
  179. Initiates the HTTP request
  180.  
  181. -b
  182. Indicates @source is a bvar
  183.  
  184. -d
  185. Indicates the HTTP Data has been prepared using /HTTP Form
  186. @source will be ignored
  187.  
  188. -f
  189. Indicates @source is a file to send
  190. The entire file will be read into memory for sending
  191.  
  192. -F
  193. Indicates @source is a file to send
  194. The file will be streamed from disk
  195.  
  196. @name
  197. HTTP client instance
  198.  
  199. @source - Switch dependent(not -d)
  200. The data source to send
  201.  
  202.  
  203.  
  204. /HTTP Takeover @name @sockname
  205. Allows for another script to take over the connection
  206. Once called, the underlying socket is renamed and all other related resources for the instance are freed
  207. Only applicable from within the HTTPHead event
  208.  
  209. @name
  210. HTTP client instance name
  211.  
  212. @sockname
  213. The new sockname to use for the underlying socket
  214.  
  215. Note:
  216. This command is meant for supplemental scripts to add functionality to the base HTTP client
  217. An example of this would be a websocket script
  218.  
  219.  
  220.  
  221. /HTTP Close -w @name
  222. Closes all matching HTTP client instance
  223.  
  224. -w
  225. Indicates @name is a wildcard pattern
  226.  
  227. @name
  228. The name or wildcard pattern to use to close HTTP client instances
  229.  
  230.  
  231.  
  232. /HTTP Shutdown
  233. Closes all HTTP client instances and frees all related resources
  234.  
  235.  
  236.  
  237. $HTTP()
  238. TODO - Returns various information about the request/response
  239.  
  240.  
  241.  
  242. $HTTPMime(@ext|file)
  243. Returns the mime type for the specified file extension
  244.  
  245. @ext
  246. The extension, file path or file name to get the mime-type of
  247. The last "." delimited token will be used as the ext to look up
  248.  
  249.  
  250.  
  251. Events are emitted via signals, formatted as @event-@name
  252. @event : The event that triggered
  253.  
  254. @name : The name of the HTTP client instance that triggered the event
  255.  
  256. $1 : Will be the name of the HTTP client instance for all events
  257.  
  258. $HTTPSockErr
  259. Will be filled if any socket errors occur
  260.  
  261. $HTTPProtoErr
  262. Will be filled if any HTTP protocol errors occur
  263.  
  264. $HTTPSysErr
  265. Will be filled if any system errors occur
  266.  
  267.  
  268. HTTPOpen
  269. Emitted when the socket connection has been established or fails to connect
  270.  
  271. HTTPSend
  272. Emitted each time a portion of the request data is successfully sent
  273.  
  274. HTTPSent
  275. Emitted after the request has been sent and a response is pending
  276.  
  277. HTTPReceive
  278. Emitted each time a portion of the response is received
  279.  
  280. HTTPHead
  281. Emitted once the HTTP response head has been received
  282. $2 is the status code
  283. $3- is the status text
  284.  
  285. HTTPRedirect
  286. Emitted when an http redirect is about to be followed
  287. Redirects are followed after the body for the current request has been received
  288.  
  289. HTTPDone
  290. Emitted once the request has finished
  291. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement