HTTP library 1.0 Beta

Developed or developing a new product in PureBasic? Tell the world about it.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

HTTP library 1.0 Beta

Post by Num3 »

I've rebuilt the GetURL lib, and renamed it.

These are the new functions:
  • HTTP_Init
    HTTP_LastError_Description
    HTTP_LastError_ID
    HTTP_New_Connection
    HTTP_Set_InBuffer
    HTTP_Get_InBuffer
    HTTP_Set_Proxy
    HTTP_Set_Authorization
    HTTP_File_Size
    HTTP_File_Date
    HTTP_Download_ToFile
    HTTP_Download_ToMem
    HTTP_Get_Progress
    HTTP_Stop
There's a basic example on this distro, but no helpfile for now.

Hope you all can test it for bugs!

The install os only 35k and you can get it
»»HERE««
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

is it possible to get the source?
(Sorry, but i know your old lib)
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

I was planing to release the source code with the final distro, but here's a link to the current beta source.

And thanks for the date parsing routine, i included it on my lib :wink:

http://cosmos.oninetspeed.pt/rui_carval ... source.zip
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

Nice lib.
:D
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

i found nearly all errors again in you lib:

1.WRONG:
Base64Encoder(conc$,Len(conc$),OutputBuffer,OutputBuffer*2)

Better:
Base64Encoder(conc$,Len(conc$),OutputBuffer,Len(conc$)*2)

2.And a proxy doesn't need always a password.

3.When a proxy is used, you *MUST* give the complete url in the uri
"GET http://gpihome.de/crillion/english.txt http/1.0"

4. Location in the "request"-header is unused. When you get a "moved" (3xx)-message you must set the "location"-part as new URL.

5. Why you ask first the size "HEAD" and the with "GET"?
With "Get" you get the full header.
The end of a header is definied with chr(13)+chr(10)+chr(13)+chr(10) and it is easy too detect. And when you use a proxy, your connection is disconnected after the head.

6. "Splitted" headers aren't supported. What is, when a header is too long for one "ReceiveNetworkData(internetID,@Content$,14500)" (i mean, when the server doN't send all at one time, because of a bad connection)?

7. ?!?

Code: Select all

Procedure HTTP_Set_Authorization(ConnectionID.l, Username.s,Password.s);Set Authentication Data
EndProcedure
8. CreateThread(@int_Action(),Str(ConnectionID)+"|"+Str(#HTTP_Action_Get2File))
Bad idea, when you use threads and strings.

9. Warning:
Procedure HTTP_Stop();Stops HTTP library
ClearList(http_data())
EndProcedure
You should free memory and break all created threads.

10. Wrong errorhandling:

Code: Select all

If FindString(Content$,"404",1)
the errorcode is in the first line of the Content. With you code it is possble, that a "Content-Length: 1404" is detected as error.
bluejoke
User
User
Posts: 11
Joined: Thu Nov 11, 2004 4:30 pm
Location: Guenzburg, Bavaria, Germany
Contact:

Post by bluejoke »

Hi!

I would really enjoy to work with your new lib, if you could do that updates, GPI proposed.
I was really sorry that your old Lib didn't provide a possibility to download files with a variable Size,
so if it works now, I will try to use it.

thanks a lot,
Simon

Please excuse all my mistakes in the post :oops:,
I tried my best to write correct English
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

>I was really sorry that your old Lib didn't provide a possibility to download
>files with a variable Size,
>so if it works now, I will try to use it.

What kind of download?
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

He means when the server does not give the size of the file to be downloaded...
I'm working on the bug fixes and on that too ;)
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

Num3 wrote:He means when the server does not give the size of the file to be downloaded...
Does somebody have a example?
(i manged partial get, and i think i have engouth information for the "unsize"-download).
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

..

Post by NoahPhense »

Very kewl.. this lib/source has many applications..

thanks for keeping it alive..

- np
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

examples for this downloadtype:

http://shinji.chaosnet.org/phpinfo.php
http://shinji.chaosnet.org/phpinfo.php? ... AA001ACF42

GPI
(btw: The server must send HTTP1.1! otherwise this will not work. I'm sorry, but i don't know, how to detect the serverdisconnect...)
bluejoke
User
User
Posts: 11
Joined: Thu Nov 11, 2004 4:30 pm
Location: Guenzburg, Bavaria, Germany
Contact:

Post by bluejoke »

Num3 is right:
does it work if the server doesn't tell you the size?
I think, it happens for example when the server sends you the output of an PHP-Script

The Script of freak is able to do it, but I don't get it running, so I hope you'll feature it soon, because your solution is much easier to understand than the COM-Object one of freak

sry for my bad english

Simon
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

User avatar
DoubleDutch
Addict
Addict
Posts: 3220
Joined: Thu Aug 07, 2003 7:01 pm
Location: United Kingdom
Contact:

Post by DoubleDutch »

Num3: Any news about your http library?

-Anthony
https://deluxepixel.com <- My Business website
https://reportcomplete.com <- School end of term reports system
User avatar
Progi1984
Addict
Addict
Posts: 806
Joined: Fri Feb 25, 2005 1:01 am
Location: France > Rennes
Contact:

Post by Progi1984 »

What are the nws about this intersting library ?
Post Reply