Re: [go-nuts] malformed HTTP response

376 views
Skip to first unread message

Keith Morrow

unread,
May 23, 2013, 1:30:21 PM5/23/13
to chen bo, golan...@googlegroups.com
For people without google translate:

Ladies and gentlemen, I have a problem.

Use http.Get (url) requests a page, the content is 0 or 1 return

golang will think malformed HTTP response


View code, it was such a judgment, do not know what the reasons for judgment?

pkg / net / http / response.go

f: = strings.SplitN (line, "", 3)
if len (f) <2 {dStringError {"malformed HTTP response", line}
return nil, & badStringError {"malformed HTTP response", line}
}

How to solve this problem? Ask you

2013/5/23 chen bo <fay...@gmail.com>
各位,我遇到一个问题。

使用 http.Get(url) 请求一个页面时,返回内容为    0 或 1

golang就会认为 malformed HTTP response 


查看代码,原来是这样判断的,不知道这样判断的理由什么?

pkg/net/http/response.go

  f := strings.SplitN(line, " ", 3)
    if len(f) < 2 {dStringError{"malformed HTTP response", line}
        return nil, &badStringError{"malformed HTTP response", line}
    }

怎么解决这个问题?请教各位

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kyle Lemons

unread,
May 23, 2013, 7:24:58 PM5/23/13
to chen bo, golang-nuts
2013/5/23 chen bo <fay...@gmail.com>
各位,我遇到一个问题。

使用 http.Get(url) 请求一个页面时,返回内容为    0 或 1

golang就会认为 malformed HTTP response 


查看代码,原来是这样判断的,不知道这样判断的理由什么?

pkg/net/http/response.go

  f := strings.SplitN(line, " ", 3)
    if len(f) < 2 {dStringError{"malformed HTTP response", line}
        return nil, &badStringError{"malformed HTTP response", line}
    }

This code is not checking for the length of the body, it's splitting the first line of the response, which will be something like
HTTP/1.1 200 OK

The actual content follows after a series of headers and a blank line.
Reply all
Reply to author
Forward
0 new messages