Skip to content

Instantly share code, notes, and snippets.

View marceloandrader's full-sized avatar
🏠
Working from home

Marcelo Andrade marceloandrader

🏠
Working from home
View GitHub Profile
@marceloandrader
marceloandrader / controller.rb
Created March 30, 2011 21:31
bug with layout on rails 3 upgraded from 2.3.8
# on application_controller.rb
layout "application"
# on other_controller.rb
# this doesn't work
render :action => :show
# this work
render :action => :show, :layout => "other_layout"
# I've tried on application_controller this:
PS1="\n\[\e[32;1m\](\[\e[37;1m\]\u\[\e[32;1m\])-(\[\e[37;1m\]jobs:\j\[\e[32;1m\])-(\[\e[37;1m\]\w\[\e[32;1m\])\n(\[\[\e[37;1m\]! \!\[\e[32;1m\])-> \[\e[0m\]"
+ (Response *)sendRequest:(NSMutableURLRequest *)request withUser:(NSString *)user andPassword:(NSString *)password {
//lots of servers fail to implement http basic authentication correctly, so we pass the credentials even if they are not asked for
//TODO make this configurable?
NSURL *url = [request URL];
if(user && password) {
NSString *authString = [[[NSString stringWithFormat:@"%@:%@",user, password] dataUsingEncoding:NSUTF8StringEncoding] base64Encoding];
[request addValue:[NSString stringWithFormat:@"Basic %@", authString] forHTTPHeaderField:@"Authorization"];
NSString *escapedUser = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)user, NULL, (CFStringRef)@"@.:", kCFStringEncodingUTF8);