|
-
Jun 18th, 2011, 01:10 AM
#1
Thread Starter
Addicted Member
[RESOLVED] why do i always have issues with winhtttp
It never fails just when i think i have all my little issues figured out with the help from this forum, i always run into yet another issue..
here's my problem now.
I use the following to get my pdf's file sizes so i know the size before i start the download,,
Code:
Set Req = New WinHttp.WinHttpRequest
Req.Option(WinHttpRequestOption_EnableRedirects) = True
Req.Open "HEAD", url, vbCrLf
Req.Send
Size = Req.GetResponseHeader("Content-Length")
Stats = Req.Status
only now the site that has the files has changed something,cause now i have to do a work around like this just to get the file size without downloading the whole file first.
Code:
Private Sub Req_OnResponseDataAvailable(Data() As Byte)
Req.Abort
End Sub
Private Sub Req_OnResponseStart(ByVal Status As Long, ByVal ContentType As String)
On Error Resume Next
Size = Req.GetResponseHeader("Content-Length")
Stats = Req.Status
End Sub
i had to add a timer set to at least 0.8 just keep the flow of information from screwing up and skipping files ,it works fine but it's sooo sloooow now
if i try and use HEAD on the site as before i get an error,,so i'm assuming they have blocked HEAD requests??? or something.
Could someone who knows a little more about winsock, or winhttp etc. help me find a faster alternative than what i'm doing in the second code..i can send you link to one of the pdf files, but i will send it only in a PM,,since the file and link are proprietary in nature.
Thanks ,
Rick
-
Jun 18th, 2011, 09:59 AM
#2
Re: why do i always have issues with winhtttp
Not sure where you copy/pasted your code from but:
Code:
Req.Open "HEAD", url, vbCrLf
... isn't correct. The Async argument is Boolean, as in:
Code:
Req.Open "HEAD", url, False
Once you address that you should not need the event handler and you won't be tripping over your shoelaces and can get rid of your Timer.
As for HEAD requests, well what is the .Status value? Have you printed the results from .GetAllResponseHeaders() ??
Last edited by dilettante; Jun 18th, 2011 at 10:03 AM.
-
Jun 18th, 2011, 10:00 AM
#3
Thread Starter
Addicted Member
Re: why do i always have issues with winhtttp
i'll try that change and let ya know if that fixes it
Edit: Nop I get the same result either way bud, the vbcrlf lets the site know where the end of the link is,,or at least i believe that's the reason it's there..not sure really..
just know the same results either way
Last edited by RRice; Jun 18th, 2011 at 10:11 AM.
-
Jun 18th, 2011, 12:13 PM
#4
Thread Starter
Addicted Member
Re: why do i always have issues with winhtttp
If you will except i can PM you the link i'm working with,,and then you can try and see if you can get it to work
-
Jun 18th, 2011, 02:03 PM
#5
Thread Starter
Addicted Member
Re: why do i always have issues with winhtttp
this is so weird..i can take a link to a pdf from the site i'm having issues with and stick it in IDM and the file size pops right up before i even hit the download button..so how is the file size gotten in IDM,, grrr
my head hurts
-
Jun 18th, 2011, 03:17 PM
#6
Thread Starter
Addicted Member
Re: why do i always have issues with winhtttp
i need a way of downloading just about the first 4k or whatever is needed in order to get the header, and then end the request and start a new request..
that seems to be the only way to get this link to show the file size from the web site,,it won't show the size the usual way , i've tried all kinds of different things,,and it's a nogo that way.
-
Jun 18th, 2011, 08:38 PM
#7
Thread Starter
Addicted Member
Re: why do i always have issues with winhtttp
well i guess the code i came up with will have to work..i had a bit of trouble getting the code to actually stop when i hit my stop button..the program seemed to stop but it wouldn't let me back into the vb IDE to click either the pause or the stop in there,,so i had to add a little piece of my for loop to it..
like A = whatever my to field has in it..that way the program assumed it reached the end of the count and kindly stopped :-)
-
Jun 20th, 2011, 11:46 PM
#8
Thread Starter
Addicted Member
Re: why do i always have issues with winhtttp
Issue wasn't with the way i was trying to get the info after all..turned out they moved the server to Korea lol and are converting all pdf's to djvu grr
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|