Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4151

Troubleshooting • picow : AP_IF , HTML form method=post : Computer browser Vs Mobile android browser

$
0
0
Hai!
I have set up the picow as network.WLAN(network.AP_IF) to use it as a standalone web server. Connected the socket. Created a simple webpgae with a form and input boxes to send some info to picow using method=POST

Every thing works fine . However the received content do not contain the input data (payload) when send from opera, chrome, IP and from another laptop with windows 11 EDGE too. When I connect using android mobile , I get the input data . I have tried practically everything that I could with the code changing enctype etc etc.

When I change the form submission method to GET, I get the data along with the URL which is received in the beginning of the received stream.

This means the browsers truncate the data probably due to the bank line after the headers. On the inpect element pane. It shows the status as either 200 or pending for a few seconds and changes to failed status. Thonny however shows the POST received stream with only the headers.

Code:

  def singleInputPage():    html = """        <!DOCTYPE html>        <head><meta content="text/html; charset=UTF-8" >        </head>        <body style="background-color:DodgerBlue">                        <h2>Submit Data</h2>            <form action="send" method="POST" enctype="text/plain">                 <input id="det1" name="det1" type="text" style="width :200px">                <input value="Submit" type="submit"><br>            </form>        </body>        </html>    """    return htmlap = network.WLAN(network.AP_IF)ap.config(essid='PicoW-AP', password='password')  # Set your SSID and password    ap.ifconfig(('192.168.4.1','255.255.255.0','192.168.4.1','8.8.8.8'))    ap.active(True)s = socket.socket()addr = socket.getaddrinfo('0.0.0.0', 80)[0][-1]s.bind(addr)        s.listen(1)        s.setblocking(True)cl, addr = s.accept()request = cl.recv(1024)response = singleInputPage()cl.write('HTTP/1.1 200 OK\r\n')        cl.write('Content-type: text/html\r\n')       cl.write('Connection: keep-alive\r\n')       cl.sendall(response.encode())cl.close()  


here is what Thonny gets back both from computer browser and mobile browser.

received Raw data: GET / HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
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
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9

received Raw data: GET /favicon.ico HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
Accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8
Referer: http://192.168.4.1/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9


received Raw data: POST /submit HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Content-Length: 84
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://192.168.4.1
Content-Type: text/plain
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 OPR/95.0.0.0
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
Referer: http://192.168.4.1/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9


From mobile
received Raw data: GET / HTTP/1.1
User-Agent: Dalvik/2.1.0 (Linux; U; Android 12; M2101K7AI Build/SKQ1.210908.001)
Host: 192.168.4.1
Connection: Keep-Alive
Accept-Encoding: gzip

received Raw data: GET / HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36 OPR/84.0.0.0
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.7
Accept-Encoding: gzip, deflate
Accept-Language: en-IN,en-us;q=0.9,en;q=0.8

received Raw data: POST /submit HTTP/1.1
Host: 192.168.4.1
Connection: keep-alive
Content-Length: 77
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
Origin: http://192.168.4.1
Content-Type: text/plain
User-Agent: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36 OPR/84.0.0.0
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.7
Referer: http://192.168.4.1/
Accept-Encoding: gzip, deflate
Accept-Language: en-IN,en-us;q=0.9,en;q=0.8

det1=5 years
val1=

no success with disabling firewall , virus security ad blockers etc.

Trying to solve this for the past 5days without success. Has anyone encountered such issues ? can this be solved ?

Statistics: Posted by Suresh65 — Tue Oct 01, 2024 2:39 am



Viewing all articles
Browse latest Browse all 4151

Trending Articles