Page 1 of 1

Change Header in WebGadget

Posted: Thu Mar 25, 2021 8:56 am
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.

Re: Change Header in WebGadget

Posted: Sat Mar 27, 2021 4:21 pm
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.

Re: Change Header in WebGadget

Posted: Sat Mar 27, 2021 4:39 pm
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

Re: Change Header in WebGadget

Posted: Mon Mar 29, 2021 7:38 am
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

Re: Change Header in WebGadget

Posted: Mon Mar 29, 2021 12:10 pm
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)

Re: Change Header in WebGadget

Posted: Mon Mar 29, 2021 12:35 pm
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 

Re: Change Header in WebGadget

Posted: Mon Mar 29, 2021 1:47 pm
by Rjevsky
fluent wrote:OK, Headers is a Variant parameter.
Thanks! Its work!