Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:40 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : WEB Client with PicoW dont work

Author Message
Ossi
Newbie

Joined: 22/06/2023
Location: Germany
Posts: 6
Posted: 05:22pm 13 Aug 2023
Copy link to clipboard 
Print this post

Hello experts,

I have tried to read data from a web page with the PicoW.
Unfortunately it did not work. Then I tried
to use the GET request block of my FireFox.
But it is longer than a string allows.

WEB TCP CLIENT REQUEST query$, inbuf [, timeout]
Longstring does not work as parameter for query$.

Also parts of the block did not work.

I always get the Bad Request error message.

Here is the program and the result:



' HTTP Client

Dim buff%(8000)

If MM.Info(ip address) = "0.0.0.0" Then
 Print "Kein WLAN  ...  Neustart ... "
 CPU restart
EndIf

WEB ntp +2, "fritz.box"  ' Germany = +2 hours summer time

Print "Connected to W-Lant ... "

Dim Query$ = "GET /index.html HTTP/1.1"+Chr$(10)+Chr$(13)
Query$ = Query$ +"Host: www.thebackshed.com"+Chr$(10)+Chr$(13)
Query$ = Query$ +"User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64;"
Query$ = Query$ +" rv:109.0) Gecko/20100101 Firefox/111.0"+Chr$(10)+Chr$(13)
Query$ = Query$ +"Accept: text/html"+Chr$(10)+Chr$(13)
Query$ = Query$ +"Accept-Language: de,en-US"+Chr$(10)+Chr$(13)
Query$ = Query$ +"Accept-Encoding: gzip, deflate"+Chr$(10)+Chr$(13)
Query$ = Query$ +"Connection: keep-alive"+Chr$(10)+Chr$(13)
Query$ = Query$ +Chr$(10)+Chr$(13)
Print :Print "Query$:"
Print Query$
Print "End of Query$":Print

WEB OPEN TCP CLIENT "www.thebackshed.com", 80
WEB TCP CLIENT REQUEST Query$, buff%()
WEB CLOSE TCP CLIENT
Print "Recived Buffer:"
LongString Print buff%()
Print "End of Rrecived Buffer"




> RUN
ntp address 192.168.20.1
got ntp response: 13/08/2023 18:51:38
Connected to W-Lant ...

Query$:
GET /index.html HTTP/1.1
Host: www.thebackshed.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:109.0) Gecko/20100101 Firefox/111.0
Accept: text/html
Accept-Language: de,en-US
Accept-Encoding: gzip, deflate
Connection: keep-alive


End of Query$

tcp address 208.87.135.105
Connected
Recived Buffer:
HTTP/1.1 400 Bad Request
Date: Sun, 13 Aug 2023 16:51:39 GMT
Server: Apache/2.4.37 (AlmaLinux) OpenSSL/1.1.1k
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
                                                 <html><head>
                                                             <title>400 Bad Request</title>
          </head><body>
                       <h1>Bad Request</h1>
                                           <p>Your browser sent a request that this server could not understand.<br />
                                     </p>
                                         </body></html>

End of Rrecived Buffer
>


The Optionlist:

> option list
WebMite MMBasic Version 5.07.07
OPTION COLOURCODE ON
OPTION WIFI Jathe, ****************
>


Can anyone help?
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 06:41pm 13 Aug 2023
Copy link to clipboard 
Print this post

I expect it doesn't matter but you are using

LF CR

rather than

CR LF

Just maybe it confuses things?

John
 
Ossi
Newbie

Joined: 22/06/2023
Location: Germany
Posts: 6
Posted: 08:12pm 13 Aug 2023
Copy link to clipboard 
Print this post

Hi John,

yes that was it !!!!

Have swapped the order and everything works well.

Thanks a lot    

Ossi
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9308
Posted: 11:14pm 13 Aug 2023
Copy link to clipboard 
Print this post

Wow, I would never have thought of that!
A tricky little one!
Nice job, John.
And welcome to the forums, Ossi.
Smoke makes things work. When the smoke gets out, it stops!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024