using Dispatch library for Http

View: New views
8 Messages — Rating Filter:   Alert me  

using Dispatch library for Http

by jackwidman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW

My code is this simple method.

 def testCheckPage(url:String):String = {
    try {
      var http = new Http
      var request = new Request
(url)
      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
5.0")
      val responseBody = Http (req_with_agent as_str)
      responseBody.length.toString
    } catch {
       case ex: Exception => {
         "Message: " + ex.getMessage
       }
    }
  }

For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
is thrown but the exception message is null. Any ideas?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: using Dispatch library for Http

by Ross Mellgren-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Many exceptions do not have a message, e.g. NullPointerException  
(unless thrown by hand).

Maybe:

try {
     ...
} catch {
     case ex: Exception if ex.getMessage == null => "Message: " +  
ex.toString
     case ex: Exception => "Message: " + ex.getMessage
}

-Ross

On Nov 5, 2009, at 11:45 PM, jack wrote:

>
> I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
>    try {
>      var http = new Http
>      var request = new Request
> (url)
>      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
>      val responseBody = Http (req_with_agent as_str)
>      responseBody.length.toString
>    } catch {
>       case ex: Exception => {
> "Message: " + ex.getMessage
>       }
>    }
>  }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: using Dispatch library for Http

by jackwidman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Ross, I'll try it.

On Thu, Nov 5, 2009 at 11:51 PM, Ross Mellgren <dridus@...> wrote:

Many exceptions do not have a message, e.g. NullPointerException
(unless thrown by hand).

Maybe:

try {
    ...
} catch {
    case ex: Exception if ex.getMessage == null => "Message: " +
ex.toString
    case ex: Exception => "Message: " + ex.getMessage
}

-Ross

On Nov 5, 2009, at 11:45 PM, jack wrote:

>
> I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
>    try {
>      var http = new Http
>      var request = new Request
> (url)
>      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
>      val responseBody = Http (req_with_agent as_str)
>      responseBody.length.toString
>    } catch {
>       case ex: Exception => {
>        "Message: " + ex.getMessage
>       }
>    }
>  }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >






--
Jack Widman

co-founder / cto,  Authoritude, Inc.

203-641-9355

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: using Dispatch library for Http

by jackwidman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tried and I see now that the exception is java.nio.BufferUnderflowException
Any idea what might be causing this?

On Thu, Nov 5, 2009 at 11:51 PM, Ross Mellgren <dridus@...> wrote:

Many exceptions do not have a message, e.g. NullPointerException
(unless thrown by hand).

Maybe:

try {
    ...
} catch {
    case ex: Exception if ex.getMessage == null => "Message: " +
ex.toString
    case ex: Exception => "Message: " + ex.getMessage
}

-Ross

On Nov 5, 2009, at 11:45 PM, jack wrote:

>
> I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
>    try {
>      var http = new Http
>      var request = new Request
> (url)
>      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
>      val responseBody = Http (req_with_agent as_str)
>      responseBody.length.toString
>    } catch {
>       case ex: Exception => {
>        "Message: " + ex.getMessage
>       }
>    }
>  }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >






--
Jack Widman

co-founder / cto,  Authoritude, Inc.

203-641-9355

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: using Dispatch library for Http

by Ross Mellgren-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not familiar with Dispatch, sorry, perhaps use ex.printStackTrace to see where in the Dispatch code and look up the source to see what it's doing?

-Ross

On Nov 5, 2009, at 11:59 PM, Jack Widman wrote:

Tried and I see now that the exception is java.nio.BufferUnderflowException
Any idea what might be causing this?

On Thu, Nov 5, 2009 at 11:51 PM, Ross Mellgren <dridus@...> wrote:

Many exceptions do not have a message, e.g. NullPointerException
(unless thrown by hand).

Maybe:

try {
    ...
} catch {
    case ex: Exception if ex.getMessage == null => "Message: " +
ex.toString
    case ex: Exception => "Message: " + ex.getMessage
}

-Ross

On Nov 5, 2009, at 11:45 PM, jack wrote:

>
> I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
>    try {
>      var http = new Http
>      var request = new Request
> (url)
>      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
>      val responseBody = Http (req_with_agent as_str)
>      responseBody.length.toString
>    } catch {
>       case ex: Exception => {
>        "Message: " + ex.getMessage
>       }
>    }
>  }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >






--
Jack Widman

co-founder / cto,  Authoritude, Inc.

203-641-9355




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: using Dispatch library for Http

by Timothy Perrett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Im pretty sure @n8han doesnt monitor this list - probally better to  
use the Dispatch forum:

http://n2.nabble.com/Dispatch-f3618001.html

Cheers, Tim

On 6 Nov 2009, at 04:45, jack wrote:

>
> I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
>    try {
>      var http = new Http
>      var request = new Request
> (url)
>      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
>      val responseBody = Http (req_with_agent as_str)
>      responseBody.length.toString
>    } catch {
>       case ex: Exception => {
> "Message: " + ex.getMessage
>       }
>    }
>  }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: using Dispatch library for Http

by jackwidman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did that. Thanks.

On Fri, Nov 6, 2009 at 9:12 AM, Timothy Perrett <timothy@...> wrote:

Im pretty sure @n8han doesnt monitor this list - probally better to
use the Dispatch forum:

http://n2.nabble.com/Dispatch-f3618001.html

Cheers, Tim

On 6 Nov 2009, at 04:45, jack wrote:

>
> I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
>    try {
>      var http = new Http
>      var request = new Request
> (url)
>      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
>      val responseBody = Http (req_with_agent as_str)
>      responseBody.length.toString
>    } catch {
>       case ex: Exception => {
>        "Message: " + ex.getMessage
>       }
>    }
>  }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >
>






--
Jack Widman

co-founder / cto,  Authoritude, Inc.

203-641-9355

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: using Dispatch library for Http

by jackwidman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did that. Nathan said it was a problem with Scala's Source class when handling large inputs or special characters. He will change his as_str method in the Http class so that it doesn't use Source in 0.6.1.

On Fri, Nov 6, 2009 at 9:12 AM, Timothy Perrett <timothy@...> wrote:

Im pretty sure @n8han doesnt monitor this list - probally better to
use the Dispatch forum:

http://n2.nabble.com/Dispatch-f3618001.html

Cheers, Tim

On 6 Nov 2009, at 04:45, jack wrote:

>
> I'm using the Dispatch Databinder library for Http.  http://bit.ly/NPWcW
>
> My code is this simple method.
>
> def testCheckPage(url:String):String = {
>    try {
>      var http = new Http
>      var request = new Request
> (url)
>      val req_with_agent = request <:< Map("User-Agent" -> "Mozilla/
> 5.0")
>      val responseBody = Http (req_with_agent as_str)
>      responseBody.length.toString
>    } catch {
>       case ex: Exception => {
>        "Message: " + ex.getMessage
>       }
>    }
>  }
>
> For some urls, e.g., http://bae.cf.huffingtonpost.com/ , an exception
> is thrown but the exception message is null. Any ideas?
> >
>






--
Jack Widman

co-founder / cto,  Authoritude, Inc.

203-641-9355

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb@...
To unsubscribe from this group, send email to liftweb+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---