net.http: fix http.fetch(), without explicit method (default again to .get, not to .acl)

This commit is contained in:
Delyan Angelov 2023-09-06 11:50:11 +03:00
parent dac6f0b0c9
commit 330dda59c8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -6,6 +6,11 @@ module http
// The methods listed here are all of those on the list available at: // The methods listed here are all of those on the list available at:
// https://www.iana.org/assignments/http-methods/http-methods.xhtml // https://www.iana.org/assignments/http-methods/http-methods.xhtml
pub enum Method { // as of 2023-06-20 pub enum Method { // as of 2023-06-20
get // Note: get ***should*** remain the first value here, to ensure that http.fetch() by default will use it
head
post
put
// uncommon ones:
acl acl
baseline_control baseline_control
bind bind
@ -14,8 +19,6 @@ pub enum Method { // as of 2023-06-20
connect connect
copy copy
delete delete
get
head
label label
link link
@lock @lock
@ -29,11 +32,9 @@ pub enum Method { // as of 2023-06-20
options options
orderpatch orderpatch
patch patch
post
pri pri
propfind propfind
proppatch proppatch
put
rebind rebind
report report
search search
@ -53,6 +54,8 @@ pub fn (m Method) str() string {
.get { 'GET' } .get { 'GET' }
.head { 'HEAD' } .head { 'HEAD' }
.post { 'POST' } .post { 'POST' }
.put { 'PUT' }
// uncommon ones:
.acl { 'ACL' } .acl { 'ACL' }
.baseline_control { 'BASELINE-CONTROL' } .baseline_control { 'BASELINE-CONTROL' }
.bind { 'BIND' } .bind { 'BIND' }
@ -77,7 +80,6 @@ pub fn (m Method) str() string {
.pri { 'PRI' } .pri { 'PRI' }
.propfind { 'PROPFIND' } .propfind { 'PROPFIND' }
.proppatch { 'PROPPATCH' } .proppatch { 'PROPPATCH' }
.put { 'PUT' }
.rebind { 'REBIND' } .rebind { 'REBIND' }
.report { 'REPORT' } .report { 'REPORT' }
.search { 'SEARCH' } .search { 'SEARCH' }
@ -101,6 +103,8 @@ pub fn method_from_str(m string) Method {
'GET' { Method.get } 'GET' { Method.get }
'HEAD' { Method.head } 'HEAD' { Method.head }
'POST' { Method.post } 'POST' { Method.post }
'PUT' { Method.put }
// uncommon ones:
'ACL' { Method.acl } 'ACL' { Method.acl }
'BASELINE-CONTROL' { Method.baseline_control } 'BASELINE-CONTROL' { Method.baseline_control }
'BIND' { Method.bind } 'BIND' { Method.bind }
@ -125,7 +129,6 @@ pub fn method_from_str(m string) Method {
'PRI' { Method.pri } 'PRI' { Method.pri }
'PROPFIND' { Method.propfind } 'PROPFIND' { Method.propfind }
'PROPPATCH' { Method.proppatch } 'PROPPATCH' { Method.proppatch }
'PUT' { Method.put }
'REBIND' { Method.rebind } 'REBIND' { Method.rebind }
'REPORT' { Method.report } 'REPORT' { Method.report }
'SEARCH' { Method.search } 'SEARCH' { Method.search }
@ -137,6 +140,6 @@ pub fn method_from_str(m string) Method {
'UPDATE' { Method.update } 'UPDATE' { Method.update }
'UPDATEREDIRECTREF' { Method.updateredirectref } 'UPDATEREDIRECTREF' { Method.updateredirectref }
'VERSION-CONTROL' { Method.version_control } 'VERSION-CONTROL' { Method.version_control }
else { Method.get } // should we default to GET? else { Method.get } // always default to .get, it is the safest
} }
} }