1. EuMVC:Dealing with favicon request

I'm getting an error using Eu-MVC:

c:\eu_include\mvc\include\mvc\app.e:604 in function handle_request()  
subscript value 5 is out of bounds, reading from a sequence of length 4 - in assignment to 'func_id'  
    path_info = {47'/',102'f',97'a',118'v',105'i',99'c',111'o',110'n',46'.', 
105'i',99'c',111'o'} 
    request_method = {71'G',69'E',84'T'} 
    query_string = {} 
    exit_code = 0 
    route_found = 0 
    default_route = 0 
    response = {} 
    patterns = { 
                 {47'/',115's',117'u',98'b',99'c',97'a',108'l',99'c'}, 
                 {47'/',115's',117'u',98'b',99'c',97'a',108'l',99'c',47'/', 
105'i',110'n',116't',101'e',103'g',101'e',114'r',62'>',47'/',60'<',97'a', 
117'u',116't',104'h'}, 
                 {94'^',47'/',46'.',43'+',36'$'}, 
                 {47'/'} 
               } 
    candidates = { 
                   {94'^',47'/',46'.',43'+',36'$'} 
                 } 
    i = 4 
    pattern = <no value> 
    i = 1 
    pattern = {94'^',47'/',46'.',43'+',36'$'} 
    path = {42'*'} 
    name = {117'u',110'n',107'k',110'n',111'o',119'w',110'n'} 
    vars = {} 
    methods = 21 
    func_id = <no value> 
    matches = <no value> 
    request = <no value> 
    pattern = <no value> 
    path = <no value> 
    name = <no value> 
    vars = <no value> 
    methods = <no value> 
    func_id = <no value> 
    request = <no value> 

What's the fix for this?

new topic     » topic index » view message » categorize

2. Re: EuMVC:Dealing with favicon request

euphoric said...

I'm getting an error using Eu-MVC:

c:\eu_include\mvc\include\mvc\app.e:604 in function handle_request()  
subscript value 5 is out of bounds, reading from a sequence of length 4 - in assignment to 'func_id'  

What's the fix for this?

I fixed this a while ago. You need to pull a new copy of the source from GitHub.

-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: EuMVC:Dealing with favicon request

ghaberek said...
euphoric said...

I'm getting an error using Eu-MVC:

c:\eu_include\mvc\include\mvc\app.e:604 in function handle_request()  
subscript value 5 is out of bounds, reading from a sequence of length 4 - in assignment to 'func_id'  

What's the fix for this?

I fixed this a while ago. You need to pull a new copy of the source from GitHub.

I figured that'd be the case! grin

new topic     » goto parent     » topic index » view message » categorize

4. Re: EuMVC:Dealing with favicon request

ghaberek said...

I fixed this a while ago. You need to pull a new copy of the source from GitHub.

Does downloading the ZIP not get me the latest code? I get the same error as before after having replaced the old code with the new stuff... apparently.

new topic     » goto parent     » topic index » view message » categorize

5. Re: EuMVC:Dealing with favicon request

euphoric said...

Does downloading the ZIP not get me the latest code? I get the same error as before after having replaced the old code with the new stuff... apparently.

The problem is this function in my app:

function unknown(object request) 
sequence url = map:get(request,"PATH_INFO") 
    map response = map:new() 
	addHomePageVars(response) 
	map:put(response, "error", "Unknown path: " & map:get(request,"PATH_INFO")) 
    return redirect( url_for("index", response ) ) 
end function 
app:route("*", "unknown") 

It's supposed to be a catch-all for unknown paths. I guess I need a different approach...

new topic     » goto parent     » topic index » view message » categorize

6. Re: EuMVC:Dealing with favicon request

euphoric said...

Does downloading the ZIP not get me the latest code?

Yes.

euphoric said...

I get the same error as before after having replaced the old code with the new stuff... apparently.

The problem is this function in my app:

function unknown(object request) 
sequence url = map:get(request,"PATH_INFO") 
    map response = map:new() 
	addHomePageVars(response) 
	map:put(response, "error", "Unknown path: " & map:get(request,"PATH_INFO")) 
    return redirect( url_for("index", response ) ) 
end function 
app:route("*", "unknown") 

It's supposed to be a catch-all for unknown paths. I guess I need a different approach...

TBH I haven't really tested the "catch all" approach very much and IMO it'd be safer to maintain specific routes instead of trying to handle "everything."

You should be able to use a static handler for this instead. You can add multiple routes to the same handler.

function static( object request ) 
 
    sequence path_info = map:get( request, "PATH_INFO" ) 
    sequence local_file = canonical_path( "." & path_info ) 
 
    if search:begins( current_dir(), local_file ) and file_exists( local_file ) then 
        return send_file( local_file ) 
    end if 
 
    return response_code( 404 ) 
end function 
app:route( "/static/.+", "static" ) -- any file in the "./static" directory 
app:route( "/favicon\\.ico", "static" ) -- the specific file "favicon.ico" 

Note the backslash in second route; because these are regex patterns you have to escape the period.

-Greg

new topic     » goto parent     » topic index » view message » categorize

7. Re: EuMVC:Dealing with favicon request

ghaberek said...
euphoric said...

Does downloading the ZIP not get me the latest code?

Yes.

Dang. That ain't right.

new topic     » goto parent     » topic index » view message » categorize

8. Re: EuMVC:Dealing with favicon request

ghaberek said...

You should be able to use a static handler for this instead. You can add multiple routes to the same handler.

What happens if I don't provide a route for a given URL? Does it try to serve up a static file anyway?

new topic     » goto parent     » topic index » view message » categorize

9. Re: EuMVC:Dealing with favicon request

euphoric said...
ghaberek said...
euphoric said...

Does downloading the ZIP not get me the latest code?

Yes.

Dang. That ain't right.

Sorry, I meant "Yes, it gives you the latest code." It's just zipping whatever you'd get with a git clone.

euphoric said...
ghaberek said...

You should be able to use a static handler for this instead. You can add multiple routes to the same handler.

What happens if I don't provide a route for a given URL? Does it try to serve up a static file anyway?

By default it will return a 404 error with the message "The requested URL was not found on this server."

If you have a default route handler set (the "*" catch-all) then it will call up that handler and you'll need to respond accordingly.

You can see that behavior here: https://github.com/OpenEuphoria/euphoria-mvc/blob/master/include/mvc/app.e#L708

And if you're running through a real web server like Nginx or Apache, then that's beyond the scope of EuMVC and it may serve up static files depending on your configuration, so be careful.

-Greg

new topic     » goto parent     » topic index » view message » categorize

10. Re: EuMVC:Dealing with favicon request

ghaberek said...

And if you're running through a real web server like Nginx or Apache, then that's beyond the scope of EuMVC and it may serve up static files depending on your configuration, so be careful.

I'm using Apache. I will have to figure out if/how that favicon file gets served up.

Would that also apply to <img>s?

new topic     » goto parent     » topic index » view message » categorize

11. Re: EuMVC:Dealing with favicon request

euphoric said...

I'm using Apache. I will have to figure out if/how that favicon file gets served up.

Would that also apply to <img>s?

Well like I said, that depends entirely on your configuration. Here is the example .htaccess configuration from the EuMVC project:

# Add CGI handler for index.esp 
AddHandler cgi-script .esp 
DirectoryIndex index.esp 
Options +ExecCGI 
 
# Send all non-existent paths to index.esp 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.esp/$1 [L,NS] 
 
# Deny access to these file patterns 
<Files ~ ".(cfg|err|edb)$"> 
    Deny from all 
</Files> 

Any files that do exist will get served up when they're requested, unless denied by the <Files> block.

Any files that don't exist will be sent through index.esp. Since index.esp is running EuMVC, it will return a final 404 error if it cannot find a matching route for the requested path.

I'd recommend putting important files outside of the DocumentRoot altogether, especially any local database files you might be using. Then just access them using relative paths instead.

General "CGI best practices" are beyond the scope of EuMVC and it's worth reading through the Apache manual and doing some manual testing to ensure you understand how it all works.

-Greg

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu