Retrieve header info from Webgadget
Posted: Sun Oct 31, 2010 2:29 am
This is probably easier than I'm making it out to be, but it's been killing me for a while. All I'm trying to do is get the header information (specifically the 'Content-Type') from a web page that's loaded into a webgadget. I've been battling it all day long and it's driving me nuts!!!
I'm trying to do it using COMatePLUS, as I figured that would make it easy to access, but I don't know what the "command string" is supposed to be to get to it.
Can anybody help me? Here's a sample of what I'm trying to do:
I've tried seemingly dozens of variations on "Content-Type" in the 'GetStringProperty()' function call. (e.g. "ResponseHeaders\Content-Type", "GetResponseHeaders\Content-Type", etc.) Maybe that's not even the correct function to use?
Or is there an easy way to do it without COMatePLUS? Or is there not even an easy way to do it?
Any help would be greatly appreciated.
Thank you.
e.levy
I'm trying to do it using COMatePLUS, as I figured that would make it easy to access, but I don't know what the "command string" is supposed to be to get to it.
Can anybody help me? Here's a sample of what I'm trying to do:
Code: Select all
XIncludeFile "COMatePLUS.pbi"
OpenWindow(0, 10,10,1000,1000, "mime test")
TextGadget(1, 10, 10, 45, 20, "Address:")
StringGadget(2, 60, 10, 250, 20, "")
ButtonGadget(3, 320, 10, 50, 20, "Go ->")
ButtonGadget(4, 390, 10, 50, 20, "Exit")
WebGadget(5, 10, 40, 980, 950, "http://www.honda.com", #PB_Web_BlockPopups)
TextGadget(6, 460, 10, 150, 20, "")
TextGadget(7, 630, 10, 100, 20, "Document Type:")
TextGadget(8, 730, 10, 250, 20, "")
Define MimeType.s, x.i
Global MyBrowser.COMateObject
; Wrap the webgadget
MyBrowser = COMate_WrapCOMObject(GetWindowLong_(GadgetID(5), #GWL_USERDATA))
Repeat
x = WaitWindowEvent()
Select x
Case #PB_Event_Gadget
Select EventGadget()
Case 3 ; Pushed the 'Go ->' button
SetGadgetText(5, GetGadgetText(2))
Case 4 ; Exiting the program
End
Case 5 ; Ah yes, the webgadget
Select EventType()
Case #PB_EventType_DownloadStart
SetGadgetText(6, "Webgadget is busy")
SetGadgetText(8, "")
Case #PB_EventType_DownloadEnd
SetGadgetText(6, "Webgadget is finished")
SetGadgetText(2, GetGadgetText(5))
; Now get the document type
MimeType = MyBrowser\GetStringProperty("Content-Type")
If MimeType <> ""
SetGadgetText(8, MimeType)
Else
MessageRequester("COMate Error", COMate_GetLastErrorDescription())
EndIf
EndSelect
EndSelect
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
Or is there an easy way to do it without COMatePLUS? Or is there not even an easy way to do it?
Any help would be greatly appreciated.
Thank you.
e.levy