My problem concerns post_handler(httpd_req_t *req) function in the http_serwer example.
The response which gets back from my phone to ESP eg. looks like this: var1=aaa&var2=bbb
So, how to change the separator '&' in this response?
I was looking for any info in httpd_txrx.c but I didn't find it.
How to change separator in response from http_server
Re: How to change separator in response from http_server
From your description, it sounds like it is your phone that sends the parameters, not the ESP. The ampersand (&) is the standard separator used in requests, why do you want to change that?
Re: How to change separator in response from http_server
I would like to configure WiFi password which contains '&',
but this char separates variables inside response, so it generates read fail.
but this char separates variables inside response, so it generates read fail.
-
- Posts: 9769
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to change separator in response from http_server
Suggest you read up on the http specs. Queries like the ones you use are urlencoded, so any 'breaking' characters like & are escaped. (&, specifically, gets replaced by %26.)
Re: How to change separator in response from http_server
Ok, but is it possible to get something like eg. var1aaavar2bbb instead var1=aaa&var2=bbb using esp_idf?
-
- Posts: 9769
- Joined: Thu Nov 26, 2015 4:08 am
Re: How to change separator in response from http_server
How do you mean 'to get something like' that? Get from where?
Re: How to change separator in response from http_server
I'm guessing you'll need to do that yourself because it's not something anyone else would want. Just search for every = and &, then remove them from the string.
char *src = "var1=aaa&var2=bbb";
char *dst;
dst = src;
while (*src)
{
if ((*src == '=') || (*src == '&'))
{
src++;
continue;
}
*dst++ = *src++
}
*dst = 0;
Re: How to change separator in response from http_server
why you want do these?
how you parse the vars and value what you get?
params & and value = are html standard
Your theme post sounds more
-> "How Set Query String Parameters"
-> "How Send Query String Parameters"
-> "How Get Query String Parameters"
-> "How Parse Query String Parameters"
like @fly135 give u "Http_Server_Response_Send" example, if you want not use the html rule in your usually esp32_http_send routine / send of data from your http_server on esp32
then you must send "custom" response var1Notvar2sovar3goodvar4ideavar5bettervar6usevar7standardvar8query
for standard Parse/Query ect -
there are standard routines for this available
example in other language client side .. :
Code: Select all
var url_string = "http://www.myesp32server.com/user_info.html?var1=1&var2=3&var3=m2-m3-m4-m5";
var url = new URL(url_string);
var c = url.searchParams.get("c");
console.log(c);
.. then you must write your own "GET Code"on client side too
is possible - yes - but is it usefull -no-
you can do an enc response ( encrypted ) which inert all vars and you have a client side custom html
which can dec (decrypt ) it.. but this is an other theme and exist in esp-idf also.
hope this helps in your code design - but i suggest you to start understand standards,
then change it for your customly use or create it basicly new
not sure in which language you want start/work/do this
perhabs this 27 examples can be a good begin
parse URL's..
also to learn/hear more about programing language inside and outside the universe
..the listed 27 examples in the link is part of usually knowledge..
..
sure
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Who is online
Users browsing this forum: No registered users and 128 guests