Apache Http Get Example

Posted on  by admin


Normal string-valued functions take one string as argument and return a string. Functions names are not case sensitive. Modules may register additional functions.

The grep command tells the machine to only display entries with the GET request. You can substitute other Apache commands as well. For example, if you’re looking to monitor access to.jpg images, you could substitute.jpg for GET. As before, use the actual path to your server’s log file. Maven dependencies. We use maven to manage our dependencies and are using Apache HttpClient version 4.5. Add the following dependency to your project in order to make HTTP Get request method.

NameDescriptionSpecial notes
req, httpGet HTTP request header; header names may be added to the Vary header, see below
req_novarySame as req, but header names will not be added to the Vary header
respGet HTTP response header (most response headers will not yet be set during <If>)
reqenvLookup request environment variable (as a shortcut, v can also be used to access variables). ordering
osenvLookup operating system environment variable
noteLookup request noteordering
envReturn first match of note, reqenv, osenvordering
tolowerConvert string to lower case
toupperConvert string to upper case
escapeEscape special characters in %hex encoding
unescapeUnescape %hex encoded string, leaving encoded slashes alone; return empty string if %00 is found
base64Encode the string using base64 encoding
unbase64Decode base64 encoded string, return truncated string if 0x00 is found
md5Hash the string using MD5, then encode the hash with hexadecimal encoding
sha1Hash the string using SHA1, then encode the hash with hexadecimal encoding
fileRead contents from a file (including line endings, when present) restricted
filemodReturn last modification time of a file (or 0 if file does not exist or is not regular file)restricted
filesizeReturn size of a file (or 0 if file does not exist or is not regular file)restricted

The functions marked as 'restricted' in the final column are not available in some modules like mod_include.

The functions marked as 'ordering' in the final column require some consideration for the ordering of different components of the server, especially when the function is used within the <If> directive which is evaluated relatively early.

Environment variable ordering

When environment variables are looked up within an <If> condition, it's important to consider how extremely early in request processing that this resolution occurs. As a guideline, any directive defined outside of virtual host context (directory, location, htaccess) is not likely to have yet had a chance to execute. SetEnvIf in virtual host scope is one directive that runs prior to this resolution
When reqenv is used outside of <If>, the resolution will generally occur later, but the exact timing depends on the directive the expression has been used within.

When the functions req or http are used, the header name will automatically be added to the Vary header of the HTTP response, except where otherwise noted for the directive accepting the expression. The req_novary function can be used to prevent names from being added to the Vary header.

Apache Http Client Example Scala

In addition to string-valued functions, there are also list-valued functions which take one string as argument and return a wordlist, i.e. a list of strings. The wordlist can be used with the special -in operator. Functions names are not case sensitive. Modules may register additional functions.

Apache Http Get Examples


There are no built-in list-valued functions. mod_ssl provides PeerExtList. See the description of SSLRequire for details (but PeerExtList is also usable outside of SSLRequire).

Running several name-based web sites on a single IP address.

Apache http get example list

Your server has multiple hostnames that resolve to a single address, and you want to respond differently for www.example.com and www.example.org.


Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts file for local testing, but that will work only from the machine with those hosts entries.

The asterisks match all addresses, so the main server serves no requests. Due to the fact that the virtual host with ServerName www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first <VirtualHost>.


The above configuration is what you will want to use in almost all name-based virtual hosting situations. The only thing that this configuration will not work for, in fact, is when you are serving different content based on differing IP addresses or ports.




You may replace * with a specific IP address on the system. Such virtual hosts will only be used for HTTP requests received on connection to the specified IP address.

Apache Http Get Example Code

However, it is additionally useful to use * on systems where the IP address is not predictable - for example if you have a dynamic IP address with your ISP, and you are using some variety of dynamic DNS solution. Since * matches any IP address, this configuration would work without changes whenever your IP address changes.