Class

# WebRequest

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

The <span class="title-ref">WebRequest</span> object represents an HTTP request.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                      | Type                               | Read-Only | Shared |
|-------------------------------------------|------------------------------------|-----------|--------|
| `Body<webrequest.body>`                   | `String</api/data_types/string>`   | ✓         |        |
| `Method<webrequest.method>`               | `String</api/data_types/string>`   | ✓         |        |
| `MIMEType<webrequest.mimetype>`           | `String</api/data_types/string>`   | ✓         |        |
| `Path<webrequest.path>`                   | `String</api/data_types/string>`   | ✓         |        |
| `QueryString<webrequest.querystring>`     | `String</api/data_types/string>`   | ✓         |        |
| `RemoteAddress<webrequest.remoteaddress>` | `String</api/data_types/string>`   | ✓         |        |
| `Secure<webrequest.secure>`               | `Boolean</api/data_types/boolean>` | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                  | Parameters                               | Returns                            | Shared |
|---------------------------------------|------------------------------------------|------------------------------------|--------|
| `Cookie<webrequest.cookie>`           | name As `String</api/data_types/string>` | `String</api/data_types/string>`   |        |
| `Header<webrequest.header>`           | name As `String</api/data_types/string>` | `String</api/data_types/string>`   |        |
| `HeaderNames<webrequest.headernames>` |                                          | `String()</api/data_types/string>` |        |
| `Parameter<webrequest.parameter>`     | name As `String</api/data_types/string>` | `String</api/data_types/string>`   |        |
| `Reset<webrequest.reset>`             |                                          |                                    |        |

## Property descriptions

<div id="webrequest.body">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Body

**Body** As `String</api/data_types/string>`

> The data sent with the request when it's too large to be a parameter such as a file or or large amount of data.
>
> This property is read-only.

<div id="webrequest.method">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Method

**Method** As `String</api/data_types/string>`

> Returns the request type, such as GET, POST, or PUT.
>
> This property is read-only.

<div id="webrequest.mimetype">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.MIMEType

**MIMEType** As `String</api/data_types/string>`

> Gets or sets the HTTP "Content-Type" header. This is merely a convenience feature, setting the header manually using `Header<webrequest.header>` will perform the exact same task. This value defaults to "text/html".
>
> This property is read-only.

<div id="webrequest.path">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Path

**Path** As `String</api/data_types/string>`

> Returns the part of the requested url after the path, without the query string. Using the URL <http://mydomain.com/folder/file?query> as an example, this property would be set to "folder/file".
>
> This property is read-only.
>
> In the `WebApplication.HandleURL<webapplication.handleurl>` event handler, you can check the URL that was used so that you can perform different actions:
>
> ``` xojo
> Select Case Request.Path
> Case "users"
>   ' Return XML containing currently logged in users back to the client
> Case "status"
>   ' Return XML containing status information back to the client
> End Select
> ```

<div id="webrequest.querystring">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.QueryString

**QueryString** As `String</api/data_types/string>`

> Returns the query part of the requested url. Using the URL <http://mydomain.com/folder/file?query> as an example, this property would be set to "query".
>
> This property is read-only.
>
> This code in `WebApplication.HandleURL<webapplication.handleurl>` could fetch information about a user in the database and return it as XML:
>
> ``` xojo
> Select Case Request.Path
> Case "user"
>   Var id As String = Request.QueryString
>   If Not id.IsEmpty Then
>     ' Create XML containing data for the user ID
>     Var xml As String
>     xml = CreateUserXML(id)
>
>     Request.Print(xml)
>     Return True
>   End If
> End Select
> ```

<div id="webrequest.remoteaddress">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.RemoteAddress

**RemoteAddress** As `String</api/data_types/string>`

> Returns the IP Address of the browser making the request.
>
> This property is read-only.
>
> To implement a white list for web requests to your app, you can check the remote address in `WebApplication.HandleURL<webapplication.handleurl>` and ignore any that you don't approve:
>
> ``` xojo
> If Request.RemoteAddress = "192.45.34.22" Then
>   ' Do processing
>
>   Return True
> Else
>   Return False ' Don't handle the request
> End If
> ```

<div id="webrequest.secure">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Secure

**Secure** As `Boolean</api/data_types/boolean>`

> Indicates if the request came in over a secure channel.
>
> This property is read-only.

## Method descriptions

<div id="webrequest.cookie">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Cookie

**Cookie**(name As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Returns the cookie using the specified *Name* or an empty string if no such cookie exists.

<div id="webrequest.header">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Header

**Header**(name As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Gets or sets a request header using the specified *Name*. Setting a header to a blank string removes the header.

<div id="webrequest.headernames">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.HeaderNames

**HeaderNames** As `String()</api/data_types/string>`

> Returns and array of all header names.

<div id="webrequest.parameter">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Parameter

**Parameter**(name As `String</api/data_types/string>`) As `String</api/data_types/string>`

> Returns the parameter value using the specified *Name* or an empty string if no such parameter exists.

<div id="webrequest.reset">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebRequest.Reset

**Reset**

> Resets the request object back to its original state.

## Notes

You are most likely to use this in conjunction with the `WebApplication.HandleURL<webapplication.handleurl>` event handler. This event handler supplies a parameter (Request As <span class="title-ref">WebRequest</span>) that you can use to process the incoming request and send out a reply.

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | Web |
| **Operating Systems** | All |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `WebApplication.HandleURL<webapplication.handleurl>` event and `WebResponse</api/web/webresponse>` class.

</div>
