From: Bigmac Turdsplash Date: 2012-01-09T07:04:37+09:00 Subject: Http proxy, string chomp error is nil? im building a proxy, im having a problem with processing the get request i recive from the client. the client will send the proxy the get request and then the proxy sends out this same request to the servers... so, when i recieve a request from the client, ill take this header and strip out the Host: like this header="GET / HTTP/1.1 Host: www.google.com User-Agent: Mozilla/5.0 (Windows NT 5.1Firefox/8.0.1 Accept: text/html,application/xhtml+xml Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive" host = header.to_a[1].chomp[6..-1] => "www.google.com" this works every time in irb testing, but is inconsistent when my script is running, the proxy works 90% of the time. when www.yahoo.com is requested the script crashes with Host nil error but when yahoo.com is request the script works fine... GET / HTTP/1.1 Host: www.yahoo.com User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:8.0.1) Gecko/20100101 Firefox/8.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection: keep-alive Cookie: B=8tefbfp77l57r&b=4&d=YTsZzxppYELpjioeXJu1kVafe.sroIDDz5owJg--&s=db&i=AhdUsAlvafAjzjZtkcC1; F=a=.fI9HRcMvTab.ukb24sGFXCNVEqUnV6kET4hAn3W1si7nfsvB8h_xSSa5wZoY8sju.Bj7s4-&b=e70h; Y=v=1&n=35d31ktflt3pr&p=; fpc=d=dZMgXDOItm2f.klxz2sfDYNxkFevm_0AxEXHNXANYwDgrN_qJwqGHO_HqDkoHNxq0pvLiqEAAyWQSqTRNpIu3OGRXqcZJHhFM1qhL2c.5g44dNEYfgRPoOqvbhzgmVRNu3ls8RgDrnajHWeNjMlMjgJL0hKAYP2NgN3WGc2sXKDveE3.iRyd3Rdj2.92W0Aa5JXw_Ak-&v=2; CH=AgIG0TQcTwn4YAAbrGAAEuBgAA2HYAAwnWAAKZh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