Repository navigation
Expand file tree
/
Copy pathindex.md
More file actions
99 lines (80 loc) · 2.57 KB
/
Copy pathindex.md
File metadata and controls
99 lines (80 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
title: GET request method
short-title: GET
slug: Web/HTTP/Reference/Methods/GET
page-type: http-method
browser-compat: http.methods.GET
sidebar: http
---
The **`GET`** HTTP method requests a representation of the specified resource.
Requests using `GET` should only be used to request data and shouldn't contain a body.
> [!NOTE]
> The semantics of sending a message body in `GET` requests are undefined.
> Some servers may reject the request with a [4XX client error](/en-US/docs/Web/HTTP/Reference/Status#client_error_responses) response.
<table class="properties">
<tbody>
<tr>
<th scope="row">Request has body</th>
<td>No</td>
</tr>
<tr>
<th scope="row">Successful response has body</th>
<td>Yes</td>
</tr>
<tr>
<th scope="row">{{Glossary("Safe/HTTP", "Safe")}}</th>
<td>Yes</td>
</tr>
<tr>
<th scope="row">{{Glossary("Idempotent")}}</th>
<td>Yes</td>
</tr>
<tr>
<th scope="row">{{Glossary("Cacheable")}}</th>
<td>Yes</td>
</tr>
<tr>
<th scope="row">Allowed in HTML forms</th>
<td>Yes</td>
</tr>
</tbody>
</table>
## Syntax
```http
GET <request-target>["?"<query>] HTTP/1.1
```
- `<request-target>`
- : Identifies the target resource of the request when combined with the information provided in the {{HTTPHeader("Host")}} header.
This is an absolute path (e.g., `/path/to/file.html`) in requests to an origin server, and an absolute URL in requests to proxies (e.g., `http://www.example.com/path/to/file.html`).
- `<query>` {{optional_inline}}
- : An optional query component preceded by a question-mark `?`.
Often used to carry identifying information in the form of `key=value` pairs.
## Examples
### Successfully retrieving a resource
The following `GET` request asks for the resource at `example.com/contact`:
```http
GET /contact HTTP/1.1
Host: example.com
User-Agent: curl/8.6.0
Accept: */*
```
The server sends back the resource with a {{HTTPStatus("200", "200 OK")}} status code, indicating success:
```http
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Date: Fri, 21 Jun 2024 14:18:33 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Content-Length: 1234
<!doctype html>
<!-- HTML content follows -->
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- [HTTP request methods](/en-US/docs/Web/HTTP/Reference/Methods)
- [HTTP response status codes](/en-US/docs/Web/HTTP/Reference/Status)
- [HTTP headers](/en-US/docs/Web/HTTP/Reference/Headers)
- {{HTTPHeader("Range")}} header
- {{HTTPMethod("POST")}} method