1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* |
---|
3 | * soup-method.c: HTTP Method related processing. |
---|
4 | * |
---|
5 | * Copyright (C) 2001-2002, Ximian, Inc. |
---|
6 | */ |
---|
7 | |
---|
8 | #include <glib.h> |
---|
9 | |
---|
10 | #include "soup-method.h" |
---|
11 | |
---|
12 | /** |
---|
13 | * soup_method_get_id: |
---|
14 | * @method: an HTTP method |
---|
15 | * |
---|
16 | * Converts @method into a corresponding #SoupMethodId (possibly |
---|
17 | * %SOUP_METHOD_ID_UNKNOWN). |
---|
18 | * |
---|
19 | * Return value: the #SoupMethodId |
---|
20 | **/ |
---|
21 | SoupMethodId |
---|
22 | soup_method_get_id (const char *method) |
---|
23 | { |
---|
24 | g_return_val_if_fail (method != NULL, SOUP_METHOD_ID_UNKNOWN); |
---|
25 | |
---|
26 | switch (*method) { |
---|
27 | case 'H': |
---|
28 | if (g_strcasecmp (method, "HEAD") == 0) |
---|
29 | return SOUP_METHOD_ID_HEAD; |
---|
30 | break; |
---|
31 | case 'G': |
---|
32 | if (g_strcasecmp (method, "GET") == 0) |
---|
33 | return SOUP_METHOD_ID_GET; |
---|
34 | break; |
---|
35 | case 'P': |
---|
36 | if (g_strcasecmp (method, "POST") == 0) |
---|
37 | return SOUP_METHOD_ID_POST; |
---|
38 | if (g_strcasecmp (method, "PUT") == 0) |
---|
39 | return SOUP_METHOD_ID_PUT; |
---|
40 | if (g_strcasecmp (method, "PATCH") == 0) |
---|
41 | return SOUP_METHOD_ID_PATCH; |
---|
42 | if (g_strcasecmp (method, "PROPFIND") == 0) |
---|
43 | return SOUP_METHOD_ID_PROPFIND; |
---|
44 | if (g_strcasecmp (method, "PROPPATCH") == 0) |
---|
45 | return SOUP_METHOD_ID_PROPPATCH; |
---|
46 | break; |
---|
47 | case 'D': |
---|
48 | if (g_strcasecmp (method, "DELETE") == 0) |
---|
49 | return SOUP_METHOD_ID_DELETE; |
---|
50 | break; |
---|
51 | case 'C': |
---|
52 | if (g_strcasecmp (method, "CONNECT") == 0) |
---|
53 | return SOUP_METHOD_ID_CONNECT; |
---|
54 | if (g_strcasecmp (method, "COPY") == 0) |
---|
55 | return SOUP_METHOD_ID_COPY; |
---|
56 | break; |
---|
57 | case 'M': |
---|
58 | if (g_strcasecmp (method, "MKCOL") == 0) |
---|
59 | return SOUP_METHOD_ID_MKCOL; |
---|
60 | if (g_strcasecmp (method, "MOVE") == 0) |
---|
61 | return SOUP_METHOD_ID_MOVE; |
---|
62 | break; |
---|
63 | case 'O': |
---|
64 | if (g_strcasecmp (method, "OPTIONS") == 0) |
---|
65 | return SOUP_METHOD_ID_OPTIONS; |
---|
66 | break; |
---|
67 | case 'T': |
---|
68 | if (g_strcasecmp (method, "TRACE") == 0) |
---|
69 | return SOUP_METHOD_ID_TRACE; |
---|
70 | break; |
---|
71 | case 'L': |
---|
72 | if (g_strcasecmp (method, "LOCK") == 0) |
---|
73 | return SOUP_METHOD_ID_LOCK; |
---|
74 | break; |
---|
75 | case 'U': |
---|
76 | if (g_strcasecmp (method, "UNLOCK") == 0) |
---|
77 | return SOUP_METHOD_ID_UNLOCK; |
---|
78 | break; |
---|
79 | } |
---|
80 | |
---|
81 | return SOUP_METHOD_ID_UNKNOWN; |
---|
82 | } |
---|
83 | |
---|