Page 2 of 2
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Wed Jul 03, 2013 8:06 am
by Oxyandy
DarkPlayer
Thank you for the response, I read it about 6-7 hours ago, I have spent the best part of that time reading and making attempts to get something to work
Time for a coffee & clear my head a bit, haven't given up yet, more I can try some of my attempts have been close, lol
So I've made this post in the hope that maybe someone with more experience can make some use of my observations so far and give me a boost in the right direction ??

I really would like everything to be in the one exe.
Thanks
[SOLVED]
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Wed Jul 03, 2013 11:03 am
by Oxyandy
Compared to 4. (as in last post) with WireShark I got this from Curl
Code: Select all
POST /upload/in HTTP/1.1
User-Agent: Curl
Host: mysite
Accept: */*
Content-Type: multipart/form-data; boundary=----------------------------b87ebc3d2679
------------------------------b87ebc3d2679
Content-Disposition: form-data; name="fileupload1"; filename="Filename.zip"
Content-Type: application/octet-stream
<data of file snipped from here>
------------------------------b87ebc3d2679
Content-Disposition: form-data; name="press"
Upload files
------------------------------b87ebc3d2679--
Nice shows me "press" with 2 #CRLF$ before
Upload files
More to work with, going to try now
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Thu Jul 04, 2013 5:42 pm
by Oxyandy
Well I know there are no good posts about PB and Uploading files,
but let me assure anyone, it does work, and works very well !!
Even with Binary files of course !
Dont give up, and use WireShark it will show you what you are doing wrong !
I don't use the libs posted in this thread, but I really respect the detail..
Thanks for sharing to the community
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Sun Mar 09, 2014 11:52 pm
by ozzie
Many thanks for this library, DarkPlayer. It's just what I need for communicating with vMix as mentioned
here.
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Wed Mar 26, 2014 3:32 pm
by Sebert
First of all: Thank you for this Library !
EDIT/SOLVED: Sometimes writing things down is all you need to do to spot the problem.
There were some forbidden characters (":") in the filename.
I am quite new to PureBasic, I have some experience with VBA, SQL & Java though.
As an excercise I am writing a little Podcast downloader.
So far it works fine, it reads a config XML file, where the urls of the podcast feeds are stored.
Then it downloads the xml/rss file of the podcast, and reads the propertys of the items/episodes.
The plan was/is to download the single mp3 using the urls from the feed.
But somehow this doesnt't always work, the download progresses as planned, but in
the end there is nothing but a 0 kb file without an extension.
Code: Select all
Downloading to file 'J:\PodcastTest\hr-iNFO Wissenswert\Meilensteine der Popmusik - Talking Heads: Psycho Killer (1977).mp3'
Progress: 0.0000000000
Progress: 0.0752758682
Progress: 0.1505517364
Progress: 0.2258276045
Progress: 0.3011034727
Progress: 0.3763793409
Progress: 0.4516552091
Progress: 0.5269311070
Progress: 0.6022069454
Progress: 0.6774828434
Progress: 0.7527586818
Progress: 0.8280345798
Progress: 0.9033104181
Progress: 0.9785863161
This results in a 0 kb file "J:\PodcastTest\hr-iNFO Wissenswert\Meilensteine der Popmusik - Talking Heads: Psycho Killer (1977)"
Here is my basic code:
Code: Select all
XIncludeFile "disconnect.pbi" ;Must be in front of all HTTP Query Includes!!
XIncludeFile "http.pbi"
InitNetwork()
Define overwrite
Define.s EntryUrl,Ordner
EntryUrl = "http://mp3.podcast.hr-online.de/mp3/podcast/hr2_wissenswert/hr2_wissenswert_20140322_3.mp3"
Ordner = "J:\PodcastTest\hr-iNFO Wissenswert\Meilensteine der Popmusik - Talking Heads: Psycho Killer (1977).mp3"
SimpleHTTP_GET_File(EntryUrl, Ordner, overwrite.i = #True)
It works fine with other podcasts though.
Any idea/diagnosis on what may be the problem there ?
Best regards
Sebert
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Thu Apr 17, 2014 7:14 pm
by Sebert
Hi,
another question: I get "The connection aborted/timed out during the transfer!" for some files which download
just fine via browser or ReceiveHTTPFile. Is there a way to give the "SimpleHTTP_GET_File" Procedure a bit more
time to download?
Regards
Sebastian
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Sun Jun 08, 2014 2:20 pm
by said
Thanks for this excellent lib! Works great
I had to do minor modifications (e.g Content-Type allowing for application/json to pass ...) and it worked fine where cURL failed!
Hopefully the PB team will take your notes into consideration when developing a native HTTP (i said hopefully ... soon

)
Thanks again

Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Thu Jun 12, 2014 6:04 pm
by Liqu
i'm still lost about how to upload file ( for example a text/ jpg / zip file ) using SimpleHTTP_POST_RAW and SimpleHTTP_POST
would you please show me a complete example from html -> php -> pb, please
i tried using this, but failed :
Update /
i've been successfuly post text file / string
maybe i'll encrypt the content before POST it so it will be text friendly and decompress it online.
Thank you very much

Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Sun Mar 15, 2015 9:52 am
by normeus
does any one have a working example of SimpleHTTP_POST_RAW from this library?
[edited to delete my not working example]
Thank you.
Norm.
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Sun Mar 15, 2015 10:38 am
by infratec
Hi,
without checking in real:
If you send a file, you need "Content-length:" in the header.
Or you use chunks, but then you need "Transfer-Encoding: chunked".
Maybe you need also to tell the server tahtyou send it Base64 encoded.
But I would send it as binary, because it is much faster (shorter).
Bernd
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Fri Mar 20, 2015 3:14 pm
by Aming
Anyone who can make it support https? Thanks a lot.
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Sat Mar 21, 2015 12:57 am
by Poshu
Aming wrote:Anyone who can make it support https? Thanks a lot.
That would be quite a lot of work, I don't think anyone has this kind of free time.
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Mon Mar 23, 2015 8:52 pm
by normeus
infratec posted this link for HTTPS and it has worked for me ( to post/request data from googlemaps)
http://www.purebasic.fr/english/viewtop ... 13&t=58824
Norm.
Re: HTTP Library (Crossplatform, GET/HEAD/POST, chunked, gzi
Posted: Tue Feb 16, 2016 1:32 am
by tj1010
It needs all fingerprint functions updated and you can now implement SSL/TLS fallback for GET using PB functions.
EDIT: Some sites/servers use multiple Set-Cookie headers even though I believe this is against spec.. Index parameter for request header function?