HTTP protocol
BlitzMax Forums/BlitzMax Programming/HTTP protocol
| ||
This is more of a suggestion than a question. How about extending the http protocol to something like :- "http::" - uses port 80 by default as it does now. "http:<port>::" - uses <port> |
| ||
Type THTTPStreamFactory Extends TStreamFactory Method CreateStream:TStream( url:Object,proto$,path$,readable,writeable ) If proto[..4]="http" Local port=80 If proto[..5]="http:" port = proto[5..].ToInt() EndIf Local i=path.Find( "/",0 ),server$,file$ If i<>-1 server=path[..i] file=path[i..] Else server=path file="/" EndIf Local stream:TStream=TSocketStream.CreateClient( server,port ) If Not stream Return stream.WriteLine "GET "+file+" HTTP/1.0" stream.WriteLine "Host: "+server stream.WriteLine "" While Not Eof( stream ) If Not stream.ReadLine() Exit Wend Return stream EndIf End Method End Type |
| ||
Hey. That's kinda nice ;) |
| ||
Yes. I use an SMS gateway which doesn't use port 80 so it makes sense to allow one to specify the port somewhere. |
| ||
Wouldn't it be better to stick with convention and use "http::domain:port"? Personally, I'd use a TCP stream for something like that anyway. |
| ||
Either way is good for me. Sure you can code it explicitly if you like. What I'm suggesting is improving on what's already there by making it more complete so people don't have to hack it, wrap it or re-write it. |
| ||
It is already part of the http protocol that you can specify the port of a request by appending :port to the end. This is per the specification, and all browsers etc support this form of request, i.e. http://www.something.com:8080 |
| ||
I'm not sure I understand what you're getting at deakster. There are two different meanings for 'protocol' here. a) the Blitzmax protocol specifier - ie. the "incbin::", "http::", "littleendian::" bit of the url b) the http protocol itself are you saying you prefer the browser way of specifying the port, or that you believe it's handled in BM already? |