the server makes a post request with type application/x-www-form-urlencoded
(https://v.hopto.org:8083/courier?DOMAIN=v.ru&PROTOCOL=1&LANG=ru&APP_SID=63a14505f147b126)
form
AUTH_ID=bb3d6765066cdebfe32f6402c1f3a5e19846b&AUTH_EXPIRES=3600&REFRESH_ID=abbc8e650068f160b223e053178f8c8d05424f7c8ca&member_id=bf761deb0c0&status=L&PLACEMENT=MENU&PLACEMENT_OPTIONS=%7B%22ID%22%3A%221015699%22%7D
PLACEMENT_OPTIONS: {"ID":"1015699"}
here is the end of the form. I wrote my handler for
And there seems to be something wrong with that. Somehow the AUTH_ID=.. seems to get prepended before the HTTP request. While you claim you do a POST request, the debug message says
which suggests this is a GET request (with something in front of it that should not be there). To me (but I could be wrong), the thing to debug is the thing making the request rather than the Prolog server. It is only helpful that it shows the actual request.
The other option could be that the request before was supposed to be a POST request using the AUTH_ID=.. as body, but was in fact a GET request. In that case the server will not read the body and the body will be seen as the next request. If you get a POST request, you must read the body using either http_parameters/2 (for www-form-encoded) or http_read_data/3 (for any content type). AFAIK, the server does not protect against not reading the POST data. Note that on failure or error of the HTTP handler, the server will close this connection to avoid such issues.
in this version, the post request will forward the form application/x-www-form-urlencoded
I send an html page to a post request and it does a get, but the request receives a form.
I need to read the form and pass the request further without the form, can I do this? now Iām passing an empty list, but thatās probably wrong
Iām afraid I canāt parse this. Please create a minimal reproducing example. I start thinking you are doing something wrong and that this not replying the static files. The rest remains guessing and I tried that enough
curl -d "param1=value1¶m2=value2" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost/courier
the problem is solved if for a post request with content_type(āapplication/x-www-form-urlencodedā) make http_read_data(Request, Data, ),
http_reply_from_files(static_dir(.), [cache(true)], Request).
Good. As I said, a handler dealing with a POST request should always read the data. The predicates that reply a file donāt. Probably the handler should add the option method(get). http_reply_from_files/3 canāt check that as it may be called directly in a handler, but as you now do, also as part of a correct POST request. Anyway, please mark as āsolutionā.