
iso23270
Members-
Posts
9 -
Joined
-
Last visited
Everything posted by iso23270
-
Hi, I stumbled over a strange problem which I described here: https://www.autoitscript.com/forum/topic/198427-strange-wininet-problem Bottom line: If I use the _WinINet_HttpSendRequest function as is and I send additional data in the request, every second byte of the data is 0x0 - which is obviously wrong. I solved it with modifying the function like this: Func _MyWinINet_HttpSendRequest($hHttpOpenRequest, $sHeaders = Default, $vOptional = Default) ; Set data/structures up Local $iHeaders = 0, $pHeaders = 0 If $sHeaders <> Default Then $iHeaders = StringLen($sHeaders) Local $tHeaders = DllStructCreate($WIN32_TCHAR & "[" & ($iHeaders+1) & "]") DllStructSetData($tHeaders, 1, $sHeaders) $pHeaders = DllStructGetPtr($tHeaders) EndIf Local $iOptional = 0, $pOptional = 0 If $vOptional <> Default Then If IsDllStruct($vOptional) Then $iOptional = DllStructGetSize($vOptional) $pOptional = DllStructGetPtr($vOptional) Else Local $tOptional If IsBinary($vOptional) Then $iOptional = BinaryLen($vOptional) $tOptional = DllStructCreate("byte[" & $iOptional & "]") Else $iOptional = StringLen($vOptional) ; using $WIN32_TCHAR here will not work when trying to send additional paylod ; with the request, e.g. when trying REQUEST for a webdav service $tOptional = DllStructCreate("char[" & ($iOptional+1) & "]") EndIf DllStructSetData($tOptional, 1, $vOptional) $pOptional = DllStructGetPtr($tOptional) EndIf EndIf ; Make DLL call Local $avResult = DllCall($__WinINet_hDLL, _ "int", "HttpSendRequest" & $WIN32_FTYPE, _ "ptr", $hHttpOpenRequest, _ "ptr", $pHeaders, _ "dword", $iHeaders, _ "ptr", $pOptional, _ "dword", $iOptional _ ) ; Return response If @error Or Not $avResult[0] Then Return SetError(1, 0, False) Return True EndFunc ;==>_MyWinINet_HttpSendRequest
-
Scite says "code page property" as file encoding, but I tried using other encodings with the same result. Strange thing is, that using $WIN32_TCHAR (which stands for "wchar") works completly fine a couple of lines earlier, when setting the headers.
-
Solved the problem myself. The direction unicode was not bad. If I change the the SendRequest function like this it works: Func _MyWinINet_HttpSendRequest($hHttpOpenRequest, $sHeaders = Default, $vOptional = Default) ; Set data/structures up Local $iHeaders = 0, $pHeaders = 0 If $sHeaders <> Default Then $iHeaders = StringLen($sHeaders) Local $tHeaders = DllStructCreate($WIN32_TCHAR & "[" & ($iHeaders+1) & "]") DllStructSetData($tHeaders, 1, $sHeaders) $pHeaders = DllStructGetPtr($tHeaders) EndIf Local $iOptional = 0, $pOptional = 0 If $vOptional <> Default Then If IsDllStruct($vOptional) Then $iOptional = DllStructGetSize($vOptional) $pOptional = DllStructGetPtr($vOptional) Else Local $tOptional If IsBinary($vOptional) Then $iOptional = BinaryLen($vOptional) $tOptional = DllStructCreate("byte[" & $iOptional & "]") Else $iOptional = StringLen($vOptional) ; using $WIN32_TCHAR here will not work when trying to send additional paylod ; with the request, e.g. when trying REQUEST for a webdav service $tOptional = DllStructCreate("char[" & ($iOptional+1) & "]") EndIf DllStructSetData($tOptional, 1, $vOptional) $pOptional = DllStructGetPtr($tOptional) EndIf EndIf ; Make DLL call Local $avResult = DllCall($__WinINet_hDLL, _ "int", "HttpSendRequest" & $WIN32_FTYPE, _ "ptr", $hHttpOpenRequest, _ "ptr", $pHeaders, _ "dword", $iHeaders, _ "ptr", $pOptional, _ "dword", $iOptional _ ) ; Return response If @error Or Not $avResult[0] Then Return SetError(1, 0, False) Return True EndFunc ;==>_MyWinINet_HttpSendRequest Thanks for pointing me in the right direction.
-
What you see is not what I receive, it's what I *send* as a request. The answer from the webserver is an error message saying, that he can't interpret 0x0 at the first byte of payload - which is understandable. Somewhere between my function call _WinINet_HttpSendRequest and the actual packet that is leaving my computer the string '<c:calendar-query ...' gets messed up and I have no clue why or how to prevent that.
-
I'm trying to make a request to a caldav server and I'm using WinINet.au3 for this. The problem is, that the payload I'm using in my request gets mangled. Every second byte is 0x0, which obviously is wrong and the server won't understand that. I can't use winhttp requests, as the environment I'm in is using a proxy with NTLM authentication and as far as I know winhttp is not capable of using that. My code: _WinINet_Startup() $io = _WinINet_InternetOpen(Default,$INTERNET_OPEN_TYPE_PRECONFIG) $ic = _WinINet_InternetConnect($io,$INTERNET_SERVICE_HTTP,$dest,80,Default,$username,$password) $ho = _WinINet_HttpOpenRequest($ic,"REPORT","remote.php/dav/calendars/username/default/",$INTERNET_FLAG_RELOAD) _WinINet_HttpAddRequestHeaders($ho,"Content-Type: application/xml; charset=utf-8" & @CRLF, $HTTP_ADDREQ_FLAG_ADD) _WinINet_HttpAddRequestHeaders($ho,"Depth: 1" & @CRLF, $HTTP_ADDREQ_FLAG_ADD) $hs = _WinINet_HttpSendRequest($ho,Default,'<c:calendar-query xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav"><d:prop><d:getetag /><c:calendar-data /></d:prop><c:filter><c:comp-filter name="VCALENDAR"><c:comp-filter name="VEVENT"><c:time-range start="20190401T000000" end="20190402T235959"/></c:comp-filter></c:comp-filter></c:filter></c:calendar-query>') $data=_WinINet_InternetReadFile($ho,1048576) ConsoleWrite($data) _WinINet_InternetCloseHandle($ho) _WinINet_InternetCloseHandle($ic) _WinINet_InternetCloseHandle($io) _WinINet_Shutdown() Relevant code from WinINet.au3: Func _WinINet_HttpSendRequest($hHttpOpenRequest, $sHeaders = Default, $vOptional = Default) ; Set data/structures up Local $iHeaders = 0, $pHeaders = 0 If $sHeaders <> Default Then $iHeaders = StringLen($sHeaders) Local $tHeaders = DllStructCreate($WIN32_TCHAR & "[" & ($iHeaders+1) & "]") DllStructSetData($tHeaders, 1, $sHeaders) $pHeaders = DllStructGetPtr($tHeaders) EndIf Local $iOptional = 0, $pOptional = 0 If $vOptional <> Default Then If IsDllStruct($vOptional) Then $iOptional = DllStructGetSize($vOptional) $pOptional = DllStructGetPtr($vOptional) Else Local $tOptional If IsBinary($vOptional) Then $iOptional = BinaryLen($vOptional) $tOptional = DllStructCreate("byte[" & $iOptional & "]") Else $iOptional = StringLen($vOptional) $tOptional = DllStructCreate($WIN32_TCHAR & "[" & ($iOptional+1) & "]") EndIf DllStructSetData($tOptional, 1, $vOptional) $pOptional = DllStructGetPtr($tOptional) EndIf EndIf ; Make DLL call Local $avResult = DllCall($__WinINet_hDLL, _ "int", "HttpSendRequest" & $WIN32_FTYPE, _ "ptr", $hHttpOpenRequest, _ "ptr", $pHeaders, _ "dword", $iHeaders, _ "ptr", $pOptional, _ "dword", $iOptional _ ) ; Return response If @error Or Not $avResult[0] Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinINet_HttpSendRequest HTTP request: REPORT /remote.php/dav/calendars/username/default/ HTTP/1.1 Connection: Keep-Alive Content-Type: application/xml; charset=utf-8 Accept: */* Depth: 1 User-Agent: AutoIt/3.3.14.5 Host: myhost.com Content-Length: 317 Cache-Control: no-cache Cookie: cookie_test=test <.c.:.c.a.l.e.n.d.a.r.-.q.u.e.r.y. .x.m.l.n.s.:.d.=.".D.A.V.:.". .x.m.l.n.s.:.c.=.".u.r.n.:.i.e.t.f.:.p.a.r.a.m.s.:.x.m.l.:.n.s.:.c.a.l.d.a.v.".>.<.d.:.p.r.o.p.>.<.d.:.g.e.t.e.t.a.g. ./.>.<.c.:.c.a.l.e.n.d.a.r.-.d.a.t.a. ./.>.<./.d.:.p.r.o.p.>.<.c.:.f.i.l.t.e.r.>.<.c.:.c.o.m.p.-.f.i.l.t.e.r. .n.a.m.e.=.".V.C.A.L.E.N Anyone has an idea?
-
OutlookEX UDF - Help & Support (IV)
iso23270 replied to water's topic in AutoIt General Help and Support
It seems sensible to have the same defaults that are returned when using _OL_AppointmentGet, that is: EntryID,Start,End,Subject,IsRecurring -
OutlookEX UDF - Help & Support (IV)
iso23270 replied to water's topic in AutoIt General Help and Support
No problem, take your time. As I said, I can get items if I correctly specify the ReturnProperties (which I need anyway). It just took me a while to sort this out as I expected to get some "good" defaults if I don't specify anything. Maybe the solution is to just add another line for correct properties in Func _OL_ItemFind : ; Set default return properties depending on the class of items If StringStripWS($sReturnProperties, 3) = "" Then Switch $iObjectClass Case $olContact $sReturnProperties = "FirstName,LastName,Email1Address,Email2Address,MobileTelephoneNumber" Case $olDistributionList $sReturnProperties = "Subject,Body,MemberCount" Case $olNote, $olMail $sReturnProperties = "Subject,Body,CreationTime,LastModificationTime,Size" Case Else EndSwitch EndIf But I'm no expert in outlook items, so this is just a wild guess 🙂 -
OutlookEX UDF - Help & Support (IV)
iso23270 replied to water's topic in AutoIt General Help and Support
Sorry, I should have included that information: OutlookEX UDF version = 1.3.5 @AutoItVersion = 3.3.14.5 @AutoItX64 = 0 @Compiled = 0 @OSArch = X64 @OSVersion = WIN_10 Outlook version: 2016 -
OutlookEX UDF - Help & Support (IV)
iso23270 replied to water's topic in AutoIt General Help and Support
Hi, I'm not sure if I'm at the correct place here but I should give it a try. I think there's an error when using default values for fetching calendar entries. This works: $oi = _OL_ItemFind($oo, $of[1], $olAppointment, "[Start]>'01/04/2019 00:00'", "", "", "", "",4) $oi = _OL_ItemFind($oo, $of[1], $olAppointment, "[Start]>'01/04/2019 00:00'", "", "", "", "",4) I'm getting a value with the correct count. This throws an error: $oi = _OL_ItemFind($oo, $of[1], $olAppointment, "[Start]>'01/04/2019 00:00'") "C:\...\autoit\Include\OutlookEX.au3" (2947) : ==> The requested action with this object has failed.: $aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex]).value $aItems[$iCounter][$iIndex - 1] = $oItem.ItemProperties.Item($aReturnProperties[$iIndex])^ ERROR But if I specify the ReturnProperties, it works again: $oi = _OL_ItemFind($oo, $of[1], $olAppointment, "[Start]>'01/04/2019 00:00'","","","EntryID,Subject")