-
Notifications
You must be signed in to change notification settings - Fork 32
public.test.http
This function is used to check the content of a HTTP(S) web page. The aim of this function is to know if you can contact a server or not.
As an example, you can add two instance of this function, one for checking access to Internet server and an other for Intranet servers.
As result of the test, the item will be red when no connectivity at all, orange for connectivity but wrong result, or green when everything is OK.
The item won't display anything before the end of the first try.
The settings dictionary contain all informations you can set to use this function. Here is a description of each.
Key | Type | Description |
---|---|---|
title | Translatable string (see: Label translation) | Item's title shown in the menu |
computedTitle | Name of the script in Application Support CustomScripts folder |
First line on stdout will be the title |
optionalDisplay | Boolean | Will show the related item only if option key was pressed when Hello-IT menu was shown (supported in Hello-IT 1.4.0+) |
URL | String | URL to test |
mode | String | Comparaison algorithm you want to use (see below for acceptable values) |
originalString | String | Comparaison argument used by the one of the mode (expected value described below) |
ignoreSystemState | Boolean (optional) | Ignore network state reported by the system (scenario with proxy or advanced filtering can push system to report false state). Default is false |
failedConnection | String (optional) | State to report if the connection fail (see acceptable values below). Default is HITPluginTestStateError
|
unmatchingResult | String (optional) | State to report if the test fail (see acceptable values below). Default is HITPluginTestStateWarning
|
timeout | Integer (optional) | Time in seconds before considering the service is unresponsive. Default is 30 |
Mode | Description |
---|---|
md5 | Make a md5 sum and compare it to originalString
|
compare | Content must be exactly the same as originalString
|
contain | Valid if originalString is found in the answer's body |
The md5 hash can be created with curl http://www.example.com | md5
Reported state for unmatching result or fail connection can be:
HITPluginTestStateError
HITPluginTestStateWarning
HITPluginTestStateUnavailable
HITPluginTestStateOK
HITPluginTestStateNone
<dict>
<key>functionIdentifier</key>
<string>public.test.http</string>
<key>settings</key>
<dict>
<key>URL</key>
<string>https://raw.githubusercontent.com/ygini/Hello-IT/975ff834701153c3a4cdf91991a9860334645eb9/staticfiles/internet_test.txt</string>
<key>mode</key>
<string>md5</string>
<key>originalString</key>
<string>ccf41dc8262810b99142b5627d27c25e</string>
<key>ignoreSystemState</key>
<true/>
<key>repeat</key>
<integer>60</integer>
<key>title</key>
<string>Internet</string>
</dict>
</dict>
The main implementation of this function is made in the TestHTTP plugin from the main project.
Most of us were using md5 based scenario with Apple captive portal webpage. It will work until Apple change something (like in April 2017).
To avoid this issue and offer a shared URL not requiring all of us to host a target file (even if it would be better in term of security), we added a static file with random content on the project repository.
You can use two distinct URL to get it:
-
https://raw.githubusercontent.com/ygini/Hello-IT/master/staticfiles/internet_test.txt
to get the last version -
https://raw.githubusercontent.com/ygini/Hello-IT/975ff834701153c3a4cdf91991a9860334645eb9/staticfiles/internet_test.txt
to get the original version
Using the last version will give us the ability to change the content if somehow we discover a security issue related to this feature.
Using the original version will make you safe if we do a mistake.
Current md5 checksum for this content is ccf41dc8262810b99142b5627d27c25e
.
Software provided under the BSD 3-clause license. For commercial support and custom development, please contact Abelionni.
- Introduction
- Application Description
- Hello-IT as an LaunchAgent
- Preferences
- Preferences subdomain
- Functions
- Security
- Label translation
- Notifications on state change
- Images
- Logs
- Support and custom requests
- Tell it if you use it!