1

Scala Dispatch で単純な GET リクエストを実行しようとしていますが、404 エラーが発生します。予期しない応答ステータス: 404

動作する例を次に示します。

https://www.google.com/finance/info?infotype=infoquoteall&q=tsla,goog

しかし、コードのどこにエラーがあるのか​​ わかりません

import dispatch._ , Defaults._  
object Main extends App {
  //concats a the proper uri together to send to google finance   
  def composeUri ( l:List[String]) = {   
    def google = host("google.com").secure
    def googleFinance = google / "finance" / "info" 
    def googleFinanceGet = googleFinance.GET
    val csv = l mkString "," 
    googleFinanceGet <<? Map("infotype"-> "infoquoteall", "q"->csv)   
  }   

  def sendRequest (uri:Req) = { 
    val res:Future[Either[Throwable,String]] = Http(uri OK as.String).either    
    res 
  } 
  val future  = sendRequest(composeUri(List("tsla","goog")))
  for (f <- future.left) yield println("There was an error" + f.getMessage) 
} 

ありがとう!

4

1 に答える 1

3

構成された URL を (たとえば を使用して) 印刷するcomposeUri(List("tsla", "goog")).urlと、実際の例とは異なり、サブドメインが含まれていないことがわかりますwww。の定義googleを useに変更するwww.google.comと、期待どおりに動作します。

于 2014-01-14T00:17:19.427 に答える