beginner10 Posted March 19, 2022 Share Posted March 19, 2022 I'm trying to set a referrer, but it's not visible in the header, ideas? $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", "https://example.com", False) $oHTTP.SetRequestHeader("Accept", "*/*") $oHTTP.SetRequestHeader("Referrer", 'http://www.123.com') $oHTTP.Send("") $oHTTP.WaitForResponse $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status $oHeader = $oHTTP.GetAllResponseHeaders() MsgBox(0,"",$oHeader) ; Referrer is not working Func MyErrFunc() MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) EndFunc ;==>MyErrFunc Link to comment Share on other sites More sharing options...
TheXman Posted March 19, 2022 Share Posted March 19, 2022 (edited) 1 hour ago, beginner10 said: it's not visible in the header You're right, it's not visible in the response headers. That's because it does not exist in the response headers. Referrer is a request header. Request headers describe the request and response headers describe the response. So why would you expect to see that request header ("Referrer") returned by a method named GetAllResponseHeaders? There's not a GetAllRequestHeaders method because you are the one building and sending the request so you know what request headers are being sent. Of course, this assumes that your request was successful. 😉 Edited March 19, 2022 by TheXman Musashi 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
beginner10 Posted March 19, 2022 Author Share Posted March 19, 2022 @TheXman Thanks for the reply. The truth is, I haven't used Winhttp in the past. I understand what you're saying, so referres is a request header, using SetRequestHeader. But is there any way to see if that header was actually set correctly? I would have expected that after sending it with SetRequestHeader(), I could see it with GetAllResponseHeaders(). But I understand why it doesn't work that way. Thanks Link to comment Share on other sites More sharing options...
TheXman Posted March 19, 2022 Share Posted March 19, 2022 3 minutes ago, beginner10 said: But is there any way to see if that header was actually set correctly? There are numerous ways. One very easy way to see your request, is to send your request to the Postman echo api. (https://postman-echo.com/get). It will show you your request in a JSON response. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 19, 2022 Moderators Share Posted March 19, 2022 beginner10, And a third attempt (plus one with another account) - do you think we are stupid? Take a month off to think whether you are going to remain a member of this forum - because the next infraction will take the decision out of your hands. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts