File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,29 @@ String ESPWebServer::pathArg(unsigned int i) {
141
141
}
142
142
143
143
String ESPWebServer::arg (String name) {
144
+ // Special case: arg("plain") returns the body of non-multipart requests.
145
+ if (name == " plain" ) {
146
+ bool isForm = false ;
147
+ HTTPHeaders* headers = _activeRequest->getHTTPHeaders ();
148
+ HTTPHeader* ctHeader = headers->get (" Content-Type" );
149
+ if (ctHeader && ctHeader->_value .substr (0 , 10 ) == " multipart/" ) {
150
+ isForm = true ;
151
+ }
152
+ if (!isForm) {
153
+ size_t bodyLength = _activeRequest->getContentLength ();
154
+ String rv;
155
+ rv.reserve (bodyLength);
156
+ char buffer[257 ];
157
+ while (!_activeRequest->requestComplete ()) {
158
+ size_t readLength = _activeRequest->readBytes ((byte*)buffer, 256 );
159
+ if (readLength <= 0 ) break ;
160
+ buffer[readLength] = 0 ;
161
+ rv += buffer;
162
+ }
163
+ HTTPS_LOGD (" arg(\" plain\" ) returns %d bytes" , rv.length ());
164
+ return rv;
165
+ }
166
+ }
144
167
ResourceParameters *params = _activeRequest->getParams ();
145
168
std::string value;
146
169
params->getQueryParameter (std::string (name.c_str ()), value);
You can’t perform that action at this time.
0 commit comments