Skip to content

Commit

Permalink
add doc HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Syndesi committed Nov 12, 2022
1 parent f8e7fdf commit f4e91de
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
- Collection
- [MKCOL](/collection/mkcol.md)
- [GET](/collection/get.md)
- [HEAD](/collection/head.md)
- [Reference WebDAV Servers](/reference_webdav_servers.md)
- [Credits & License](/credits_and_license.md)
2 changes: 1 addition & 1 deletion docs/collection/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The status code 200 is returned when the collection/folder was found.
Request:

```bash
curl -i --basic --user 'admin:password' 'http://localhost:8000/webdav/new_folder'
curl -i --basic --user 'admin:password' -X GET 'http://localhost:8000/webdav/new_folder'
```

<!-- div:right-panel -->
Expand Down
174 changes: 174 additions & 0 deletions docs/collection/head.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# HEAD

Identical to a GET request without the response body.

!> This method does not specify specific HTTP status codes, therefore they are handled the same as plain HTTP requests.

```mermaid
graph TB
init([server receives HEAD-request])
canHandleGet{{can server handle HEAD?}}
checkURI{{does URI exist?}}
error404([return error 404])
error405([return error 405])
success200([return success 200])
redirect301([return redirect 301])
class init init
class error404 status4xx
class error405 status4xx
class success200 status2xx
class redirect301 status3xx
init --> canHandleGet
canHandleGet -- yes --> checkURI
canHandleGet -- no --> error405
checkURI -- yes --> success200
checkURI -- no --> redirect301
checkURI -- no --> error404
```

## 200: Success

<!-- panels:start -->
<!-- div:left-panel -->

The status code 200 is returned when the collection/folder was found.

Request:

```bash
curl -i --basic --user 'admin:password' --head 'http://localhost:8000/webdav/new_folder'
```

<!-- div:right-panel -->

Response

<!-- tabs:start -->

### **Dave**

```txt
HTTP/1.1 405 Method Not Allowed
Date: Sat, 12 Nov 2022 22:30:11 GMT
Content-Length: 18
Content-Type: text/plain; charset=utf-8
```

### **Apache2**

```text
HTTP/1.1 301 Moved Permanently
Date: Sat, 12 Nov 2022 22:30:26 GMT
Server: Apache/2.4.37 (Unix)
Location: http://localhost:8001/webdav/new_folder/
Content-Type: text/html; charset=iso-8859-1
```

Same request with trailing slash:

```text
HTTP/1.1 200 OK
Date: Sat, 12 Nov 2022 22:30:39 GMT
Server: Apache/2.4.37 (Unix)
Content-Type: text/html;charset=ISO-8859-1
```

### **Nginx**

```txt
HTTP/1.1 301 Moved Permanently
Server: nginx/1.22.0
Date: Sat, 12 Nov 2022 22:30:52 GMT
Content-Type: text/html
Content-Length: 169
Location: http://localhost/webdav/new_folder/
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: OPTIONS, GET, HEAD, POST, PUT, MKCOL, MOVE, COPY, DELETE, PROPFIND, PROPPATCH, LOCK, UNLOCK
Access-Control-Allow-Headers: Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite
Access-Control-Expose-Headers: ETag
Access-Control-Max-Age: 1728000
```

Same request with trailing slash:

```txt
HTTP/1.1 200 OK
Server: nginx/1.22.0
Date: Sat, 12 Nov 2022 22:31:06 GMT
Content-Type: text/html
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: OPTIONS, GET, HEAD, POST, PUT, MKCOL, MOVE, COPY, DELETE, PROPFIND, PROPPATCH, LOCK, UNLOCK
Access-Control-Allow-Headers: Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite
Access-Control-Expose-Headers: ETag
Access-Control-Max-Age: 1728000
```

<!-- tabs:end -->
<!-- panels:end -->

## 404: URI not found

<!-- panels:start -->
<!-- div:left-panel -->

The status code 404 is returned when the collection/folder URI does not exist.

Request:

```bash
curl -i --basic --user 'admin:password' --head 'http://localhost:8000/webdav/folder/which/does/not/exist'
```

<!-- div:right-panel -->

Response

<!-- tabs:start -->

### **Dave**

```txt
HTTP/1.1 404 Not Found
Date: Sat, 12 Nov 2022 22:31:27 GMT
Content-Length: 9
Content-Type: text/plain; charset=utf-8
```

### **Apache2**

```text
HTTP/1.1 404 Not Found
Date: Sat, 12 Nov 2022 22:31:40 GMT
Server: Apache/2.4.37 (Unix)
Content-Type: text/html; charset=iso-8859-1
```

### **Nginx**

```txt
HTTP/1.1 404 Not Found
Server: nginx/1.22.0
Date: Sat, 12 Nov 2022 22:31:54 GMT
Content-Type: text/html
Content-Length: 153
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: OPTIONS, GET, HEAD, POST, PUT, MKCOL, MOVE, COPY, DELETE, PROPFIND, PROPPATCH, LOCK, UNLOCK
Access-Control-Allow-Headers: Authorization,DNT,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,X-Accept-Charset,X-Accept,origin,accept,if-match,destination,overwrite
Access-Control-Expose-Headers: ETag
Access-Control-Max-Age: 1728000
```

<!-- tabs:end -->
<!-- panels:end -->

## References

- [RFC 4918: GET, HEAD for Collections](http://www.webdav.org/specs/rfc4918.html#n-get--head-for-collections)

0 comments on commit f4e91de

Please sign in to comment.