News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

HttpOpenRequest problem

Started by statis, July 19, 2011, 02:25:01 PM

Previous topic - Next topic

statis

Quote from: bomz on July 20, 2011, 02:09:56 PM
In my application IE libruary some times work incorrectly. using socket more flexibly

IE use IE dll's, wininet use common core with http(s) applications.
Winsock isn't appropriate in my case, if no one familiar wininet, i'm dead

Gunner

Use sockets or the http api , should not matter..  a boundery tells the server everything between the boundery that you define is different then the body...  You "set" the boundry in the headers.... Then you enclose your data within your boundry for the body..

What are you trying to do anyway
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

ToutEnMasm


a good sample is in the windows sdk (in c)
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\web\Wininet\Async\async.c

statis

Quote from: ToutEnMasm on July 22, 2011, 05:17:44 PM

a good sample is in the windows sdk (in c)
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\web\Wininet\Async\async.c


on msdn i find only sdk for W7 and i can't install this on my PC old XP

ToutEnMasm

Hello,
I have also XP SP3,you need just the headers files ,libraries ,binaries(tools)  and samples.
The download is well done,you can choose what you want to dowload.

statis

Quote from: statis on July 25, 2011, 01:01:29 PM
Quote from: ToutEnMasm on July 22, 2011, 05:17:44 PM

a good sample is in the windows sdk (in c)
C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\web\Wininet\Async\async.c


on msdn i find only sdk for W7 and i can't install this on my PC old XP

tanks

HttpAddRequestHeaders combination to use boundary before HttpOpenRequest isn't in this sample

ToutEnMasm


There is no sample in the sdk using HttpAddRequestHeaders .
Where to search ?

statis

Quote from: ToutEnMasm on July 25, 2011, 03:32:17 PM

There is no sample in the sdk using HttpAddRequestHeaders .
Where to search ?


Quote from: statis on July 19, 2011, 02:25:01 PM
Hello,

I need open request with multipart.

I finded this on C sample :
HINTERNET hRequest = HttpOpenRequest(hConnect, "POST",
      _T("FormActionHere"), NULL, NULL, accept, 0, 1)

Do you know value for "accept" in db form to set correctly my invoke in masm32 language ?

Tanks for all

the start of problem is on another post http://www.masm32.com/board/index.php?topic=16506.0 :

lpszVerbpost   db "POST",0
lphttp        db "HTTP/1.1",0
formact2   db "/default.html",0

invoke HttpOpenRequest,hConnect,offset lpszVerbpost,offset formact,offset lphttp,0,0,0,1

text1 db "Content-Type: multipart/form-data; boundary=AaB03x",0dh,0ah,0

invoke HttpAddRequestHeaders,hRequest,offset text1,-1,HTTP_ADDREQ_FLAG_ADD

request part is send with no error

for next step :

text2 db "--AaB03x",0dh,0ah
        db 'Content-Disposition: form-data; name="EventSource"',0dh,0ah,0dh,0ah
        db 'quickSearch_searchFieldId_',0dh,0ah,0

invoke HttpAddRequestHeaders,hRequest,offset text2,-1,HTTP_ADDREQ_FLAG_ADD

and i have 87 error (057h), windows doesn't send request part, idon't see on wireshark monitoring

i have tryed many combinations with invoke HttpAddRequestHeaders and no good results

if i use :
invoke HttpOpenRequest,hConnect,offset lpszVerbpost,offset formact,offset lphttp,0,0,x,1

i have try x="ACCEPT" and "accept" ->error HttpOpenRequest
i have try x=1 ->error HttpAddRequestHeaders on step 2

alls samples multipart request i finded on google aren't with good rfc formatting :
first declaration boundary=1234
second declaration --1234
last declaration --1234--
AND USERS HAVEN'T good result with sample :
boundary=--1234
second declaration --1234
...

RFC don't say to use wininet request only data correct format...

It's to hard use winsock with my project (more 10000 line code) for this litle part and i can't find winhttp include on masm.


ToutEnMasm

Quote
It's to hard use winsock with my project (more 10000 line code) for this litle part and i can't find winhttp include on masm.
What a piety,have you never see http://www.masm32.com/board/index.php?topic=5428.0
To be more explicit , follow the link under:
QuoteBefore translate anything,have a look at the full set of SDK header files translated
Made that and you win a complet set of sdk translated files with the winhttp translated.


ToutEnMasm

In the Winhttp.sdk,you can read
Quote
IF DEFINED(_WIN64)
;Include pshpack8.SDK
ELSE
;Include pshpack4.SDK
ENDIF

This mean that alignment of the structures must be 8 for a WIN64 system and 4 for others system.
take care of this

Gunner

WinHTTP uses Wininet, so you would include wininet.inc and includelib wininet.lib

There is no reason why you cannot  use winsock just for this part of your code.  We are going to get nowhere fast because you are only showing us snippets of your code, you have to post more code.

You are not seeing anything with WireShark because AddHeaders does not sent anything to the servers, you have to do HttpSendRequest to send to the server.

Since there is no code, lets see if you are doing what is needed.

1. InternetOpen
2. InternetConnect
3. HttpOpenRequest
4. HttpAddRequestHeaders
5. HttpSendRequest
6. HttpQueryInfo
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

statis

Quote from: Gunner on July 26, 2011, 01:54:29 PM
WinHTTP uses Wininet, so you would include wininet.inc and includelib wininet.lib

There is no reason why you cannot  use winsock just for this part of your code.  We are going to get nowhere fast because you are only showing us snippets of your code, you have to post more code.

You are not seeing anything with WireShark because AddHeaders does not sent anything to the servers, you have to do HttpSendRequest to send to the server.

Since there is no code, lets see if you are doing what is needed.

1. InternetOpen
2. InternetConnect
3. HttpOpenRequest
4. HttpAddRequestHeaders
5. HttpSendRequest
6. HttpQueryInfo

Tanks Gunner

wininet exist and why i do use winsock ?

isn't code problem, it's problem with header construction...

THIS POST IS WININET POST and IT'S QUESTION on HttpOpenRequest lpszAccept format ;)

If you know wininet multipart use you can help me, if no you loose time, sorry

Gunner

Quote from: statis on July 26, 2011, 03:00:05 PM

Tanks Gunner

wininet exist and why i do use winsock ?

isn't code problem, it's problem with header construction...

THIS POST IS WININET POST and IT'S QUESTION on HttpOpenRequest lpszAccept format ;)

If you know wininet multipart use you can help me, if no you loose time, sorry

How do you know it is not a code problem?

WinINET IS winsock.  It is a "High Level" bunch of API calls that do their thing and then use sockets.  For somethings using sockets is much easier, no problems like this.  You construct your headers and body all in one buffer, and you then send that buffer to the server.

are you doing any other internet stuff?  Does that work?  Why don't you want to post more code?  We are not going to steal your code.  Knowing multipart data is nothing..  you tell the server what your boundry is, enclose your data in the boundry and send it... 

I ask again, what are you trying to do?  What are you trying to send?

What does the lpszAcceptTypes have anything to do with this?  that is only for the client - your app, unless you are going to receive binary or encoded data just use NULL
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

statis

i don't re-repeat code, see up text on Quote from: statis on July 19, 2011, 03:25:01 pm, code is here...

winsok or not winsok that is the question  :tdown

winsock has incompatibility with alls another part in my project and with 7 external scripting modules
if i use winsok i do restart all and loose more 10000 lines codes and 300 hours of devellopement

WinINET IS winsock ! Isn't same API and if WinINET IS winsock why wininet exist ?
wininet exist and i do use

for information i have tryed to send alls boundary's with rfc format and final boundary's in one block and i have same error on HttpAddRequestHeaders
for information this mutipart formulary isn't first access on server and alls work correctly, authentification, reading pages and more, problems goes when i try to send formulary informations

for more informations accept types is important when friend use copy header with scripting soft accept is present and if header is send with no accept types no error and no result...

I ask again, what are you trying to do?  What are you trying to send?
Read post...

Gunner

You actually don't say what you are trying to send, and send where... to a php/cgi script, to a form etc... are you trying to send form data? A picture? a zip file?  some other binary data?

You do say you found this c sample... 

Winsock should have no compatibility problems with anything.  It is windows version of sockets, problem is you have to do EVERYTHING yourself, that is why WinINET came about to make life easier for programmers, it "hides" a lot from you, but its tougher to do somethings.

That is only a code snippet you have data mixed in with code.... need to see the exact code you have, that is the only way we can see what is wrong.  unless you are trying to post binary data to a form/php/cgi you don't need multi-part, application/x-www-form-urlencoded will work just fine.

I mentioned a few times, the boundry is what you make it to be... can be --------myboundry >>>>> --------myboundry--

---HeYsTaRtHeRe >>>> ---HeYsTaRtHeRe-- doesn't matter as long as the last boundry marker matches the first one with  two dashes at the end.. that is the correct way...  but if you don't want to show the code you have, I am done here, good luck in your journey..
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com