Raised This Month: $32 Target: $400
 8% 

[INC] HTTP2


Post New Thread Reply   
 
Thread Tools Display Modes
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 10-28-2013 , 12:11   Re: [INC] HTTP2
Reply With Quote #31

Quote:
Originally Posted by Black Rose View Post
What do you mean?
He wants to stream a webradio to players.
__________________
Kia is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 10-28-2013 , 14:56   [INC] HTTP2
Reply With Quote #32

That can be done with motd along with some basic HTML. You don't need this include.
__________________

Last edited by Black Rose; 10-28-2013 at 15:02.
Black Rose is offline
Kapuzzino
Member
Join Date: Jan 2014
Old 01-31-2014 , 08:31   Re: [INC] HTTP2
Reply With Quote #33

How to get the whole html web page into the variable and print it into the server's console? I'm trying like this:

PHP Code:
#include <amxmodx>
#include <http2>

new data[HTTP2_BUFFER_SIZE];

public 
plugin_init() {
    
    
register_plugin("HTTP2 Test Plugin""VERSION 1.0""AUTHOR");
    
HTTP2_Download("https://forums.alliedmods.net/showthread.php?t=223898"__"Progress");
    
}

public 
Progress(Index) {
    
    new 
len;    
    
HTTP2_getData(datacharsmax(data), len);    
    
server_print("%s",data);
    

but nothing out.
Kapuzzino is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-01-2014 , 19:46   Re: [INC] HTTP2
Reply With Quote #34

SSL is not supported yet. You have to use HTTP instead.
__________________
Black Rose is offline
Kapuzzino
Member
Join Date: Jan 2014
Old 02-02-2014 , 10:38   Re: [INC] HTTP2
Reply With Quote #35

Anyway there is nothing out.

PHP Code:
#include <amxmodx>
#include <http2>
 
#define PLUGIN    "http2 test"
#define AUTHOR    "Admin" 
#define VERSION    "1.0" 

new data[HTTP2_BUFFER_SIZE];
 
public 
plugin_init()
{    
    
register_plugin(PLUGINVERSIONAUTHOR);            
}

public 
plugin_cfg()
{
    new 
len;
    
HTTP2_Download("http://site.ru/");
    
HTTP2_getData(data,charsmax(data),len);
    
server_print("Web page is ^r^n %s ^r^n end.",data);


Last edited by Kapuzzino; 02-02-2014 at 10:38.
Kapuzzino is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-02-2014 , 15:49   Re: [INC] HTTP2
Reply With Quote #36

There's no data downloaded after you call _Download. You have to wait for either Progress or Complete. But there seems to be a problem with chunked downloads which I am currently looking into. Check complete event for any errors.

The example you posted should even give you this error:
[HTTP2] Filename or progress handler is missing.
Won't even start that download.
__________________
Black Rose is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 04-22-2014 , 19:23   Re: [INC] HTTP2
Reply With Quote #37

Include is not working very well with links like this:
http://api.gametracker.rs/demo/json/...0.180.51:27015

I did some checks, and request which is sent looks like this:
Code:
GET /demo/json/server_info/77.220.180.51 HTTP/1.1
Host: api.gametracker.rs
Plugin code:
Code:
#include < amxmodx > #include < http2 > new Buffer[ HTTP2_BUFFER_SIZE ]; public plugin_init( ) {     register_concmd( "getData", "command_getData"); } public command_getData( id ) {     HTTP2_Download( "http://api.gametracker.rs/demo/json/server_info/77.220.180.51:27015", _, "Complete", "Progress" ); } public Progress( Index ) {     new iLen;     HTTP2_getData( Buffer, charsmax( Buffer ), iLen );         server_print( "HTTP2 Progress: %d/%d(+%d)", HTTP2_getBytesReceived( Index ), HTTP2_getFilesize( Index ), iLen ); } public Complete( Index, Error ) {     new iLen;     HTTP2_getData( Buffer, charsmax( Buffer ), iLen );     server_print( Buffer ); }
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-23-2014 , 18:08   Re: [INC] HTTP2
Reply With Quote #38

Find this line inside http2.inc, in the function _HTTP2_ParseURL():
Code:
_HTTP2_ParseURL_hRegex = regex_compile("(?:(\w+):///?)?(?:([\w&\$\+\,/\.;=\[\]\{\}\|\\\^^\~%?#\-]+):([\w&\$\+\,/\.;=\[\]\{\}\|\\\^^\~%?#\-]+)@)?((?:[\w-]+\.)*[\w-]+\.[\w-]+)?(?::(\d+))?(?:/?([\w&\$\+\,/\.;=@\[\]\{\}\|\\\^^\~%\-]*))?(?:\?([\w&\$\+\,/\.;=@\[\]\{\}\|\\\^^\~%:\-]*))?(?:#([\w&\$\+\,/\.;=@\[\]\{\}\|\\\^^\~%:\-]*))?", temp, "", 0);
and replace it with this instead:
Code:
_HTTP2_ParseURL_hRegex = regex_compile("(?:(\w+):///?)?(?:([\w&\$\+\,/\.;=\[\]\{\}\|\\\^^\~%?#\-]+):([\w&\$\+\,/\.;=\[\]\{\}\|\\\^^\~%?#\-]+)@)?((?:[\w-]+\.)*[\w-]+\.[\w-]+)?(?::(\d+))?(?:/?([\w&\$\+\,/\.;=@\[\]\{\}\|\\\^^\~%:\-]*))?(?:\?([\w&\$\+\,/\.;=@\[\]\{\}\|\\\^^\~%:\-]*))?(?:#([\w&\$\+\,/\.;=@\[\]\{\}\|\\\^^\~%:\-]*))?", temp, "", 0);

I've included an exploded sample below to make it easier to understand and edit the expression where required.

I don't know why I left out ':' from the path. I tried to research possible characters for all of these fields and must have simply missed it or it wasn't mentioned anywhere. I obviously included it in the query and fragment fields so there should be no problem at all using it inside of path as it would not work unless there's a '/' in front of it, which could only happen after the port.

Thank you for noticing this problem. I appreciate it.

Please note that I am working on making this include into a plugin to make it easier to develop for it for 3rd parties. It will include a lot of new features and fail-safe functions. It will however take a couple of weeks to edit it since I have to rethink and rewrite most parts.
__________________

Last edited by Black Rose; 04-23-2014 at 18:16.
Black Rose is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 04-25-2014 , 18:43   Re: [INC] HTTP2
Reply With Quote #39

You're welcome. I'll update include with your code.

By the way i don't see any benefits of using plugin instead of this include. I think that everything is in include file. Maybe making a module is better option? With module you get "performance" benefit?

Last edited by OvidiuS; 04-25-2014 at 18:44.
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 04-25-2014 , 21:00   Re: [INC] HTTP2
Reply With Quote #40

I can't make modules.
The performance of the actual download is nothing compared to the time it takes to connect to the host. And you can't get around that.

The benefits with the plugin is that you don't have to force your plugin users to compile locally. So instead, you develop something for HTTP2 and all you do is provide the link to HTTP2 plugin and the user downloads both without having to compile any of them locally.

I will probably still keep the include updated though. But I'm waiting until I'm done with the rewrite and then basically copy/paste it.
__________________
Black Rose is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode