hubotio / hubot

A customizable life embetterment robot.

Home Page:https://hubotio.github.io/hubot/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

POST requests with 3xx response

fatcatt013 opened this issue · comments

image

I am trying to make a post request which has a correct response status code of 303. How does hubot react to this? It should redirect me to .../index.php page and return a response to GET request with status code of 200, which it seems to be doing.

The problem is that the data entered somehow dont get passed to the page. Am I entering them right?

For reference, here is the curl command I am trying to duplicate.

curl 'https://<censored>/index.php/login/submit' -L\
  -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \ 
  -H 'Accept-Language: en-US;q=0.9' \
  -H 'Cache-Control: max-age=0' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Cookie: crbs=totca4q5odkodalhk5ekmi523e0isis3' \
  -H 'Origin: https://<censored>' \
  -H 'Referer: https://<censored>/index.php/login' \
  -H 'Sec-Fetch-Dest: document' \
  -H 'Sec-Fetch-Mode: navigate' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'Sec-Fetch-User: ?1' \
  -H 'Sec-GPC: 1' \
  -H 'Upgrade-Insecure-Requests: 1' \
  -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36' \
  --data-raw 'page=login&username=hubot&password=hubot-admin' \
  --compressed

The Hubot http client isn't coded to follow redirects. You'd have to code that in this script yourself.

fetch automatically follows redirects. Try this and let me know. https://developer.mozilla.org/en-US/docs/Web/API/Fetch