File tree 1 file changed +12
-17
lines changed
1 file changed +12
-17
lines changed Original file line number Diff line number Diff line change @@ -109,27 +109,22 @@ int HttpServerConnection::onHeadersComplete(const HttpHeaders& headers)
109
109
contentType = contentType.substring (0 , endPos);
110
110
}
111
111
112
- String majorType = contentType.substring (0 , contentType.indexOf (' /' ));
113
- majorType += " /*" ;
114
-
115
112
// Content-Type for exact type: application/json
116
- // Wildcard type for application: application/*
117
- // Wildcard type for the rest*
118
-
119
- Vector<String> types;
120
- types.add (contentType);
121
- types.add (majorType);
122
- types.add (String (' *' ));
123
-
124
- for (unsigned i = 0 ; i < types.count (); i++) {
125
- const String& type = types[i];
126
- if (bodyParsers->contains (type)) {
127
- bodyParser = (*bodyParsers)[type];
128
- break ;
113
+ int i = bodyParsers->indexOf (contentType);
114
+ if (i < 0 ) {
115
+ // Wildcard type for application: application/*
116
+ contentType.setLength (contentType.indexOf (' /' ) + 1 );
117
+ contentType += ' *' ;
118
+ i = bodyParsers->indexOf (contentType);
119
+ if (i < 0 ) {
120
+ // Wildcard type for the rest*
121
+ i = bodyParsers->indexOf (String (' *' ));
129
122
}
130
123
}
131
124
132
- if (bodyParser) {
125
+ if (i >= 0 ) {
126
+ bodyParser = bodyParsers->valueAt (i);
127
+ assert (bodyParser != nullptr );
133
128
bodyParser (request, nullptr , PARSE_DATASTART);
134
129
}
135
130
}
You can’t perform that action at this time.
0 commit comments