Change Header in WebGadget

Just starting out? Need help? Post your questions and find answers here.
Rjevsky
User
User
Posts: 23
Joined: Tue Jul 18, 2017 3:41 pm

Change Header in WebGadget

Post by Rjevsky »

Hello friends!
I need to use an ip address to open the page, but the web server requires entering the site name. If you change the ip in the header to a name, the page will open successfully.
Is it possible to change the Host value in the header in webgadget?
I need a windows only solution.
fluent
User
User
Posts: 72
Joined: Sun Jan 24, 2021 10:57 am

Re: Change Header in WebGadget

Post by fluent »

Do you need to open one page, or several pages on your site?
If it is for just one page I believe I have a solution.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4946
Joined: Sun Apr 12, 2009 6:27 am

Re: Change Header in WebGadget

Post by RASHAD »

If you are Windows user you can use CMD

Code: Select all

> nbtstat %your IP%
OR

Code: Select all

>nslookup %your IP%
If I remember there is JAVA script to do the job too
which you can run it directly from PB WebGadget
Egypt my love
Rjevsky
User
User
Posts: 23
Joined: Tue Jul 18, 2017 3:41 pm

Re: Change Header in WebGadget

Post by Rjevsky »

fluent wrote:Do you need to open one page, or several pages on your site?
If it is for just one page I believe I have a solution.
yes, only one page
Rjevsky
User
User
Posts: 23
Joined: Tue Jul 18, 2017 3:41 pm

Re: Change Header in WebGadget

Post by Rjevsky »

RASHAD wrote: If I remember there is JAVA script to do the job too
which you can run it directly from PB WebGadget
I was unable to find solutions in javascript. But I saw what miracles you demonstrated using winapi.

This is my code opening page from ip adress but not change host in heder. Maby you help me IWebBrowser2 Navigate syntax

Code: Select all

  myBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(WebView_0), #GWL_USERDATA)
  header.s="Host: phone/r/n"
  myBrowser\Navigate("http://192.168.1.1",#Null,#Null,#Null,@*header)
fluent
User
User
Posts: 72
Joined: Sun Jan 24, 2021 10:57 am

Re: Change Header in WebGadget

Post by fluent »

OK, Headers is a Variant parameter.

Do it like this:

(If you get Error 400 on Bing, that means the code is working!)

Code: Select all


OpenWindow(0, 432, 42, 800, 500, "Window_0", #PB_Window_SystemMenu)

WebGadget(0, 10, 10, 780, 450, "")

Web.IWebBrowser2 = GetWindowLongPtr_(GadgetID(0), #GWL_USERDATA)
Web\put_Silent(#True)

url$ = "https://www.bing.com/"
header$  = "Host:AAA"  + #CRLF$ 

var.VARIANT
var\vt = #VT_BSTR  
var\bstrVal = @header$

Web\Navigate(url$, 0,0,0, var) 

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
Rjevsky
User
User
Posts: 23
Joined: Tue Jul 18, 2017 3:41 pm

Re: Change Header in WebGadget

Post by Rjevsky »

fluent wrote:OK, Headers is a Variant parameter.
Thanks! Its work!
Post Reply