示例#1
0
文件: gohttp.go 项目: nurse/gohttp
//export reqBody
func reqBody(self C.VALUE) C.VALUE {
	req := (*http.Request)(C.GetGoStruct(self))
	if req.Body == nil {
		return C.Qnil
	}
	return goioNew(rb_cGoIO, req.Body)
}
示例#2
0
文件: gohttp.go 项目: nurse/gohttp
//export respBody
func respBody(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	if resp.Body == nil {
		return C.Qnil
	}
	return goioNew(rb_cGoIO, resp.Body)
}
示例#3
0
文件: gohttp.go 项目: nurse/gohttp
//export respHeader
func respHeader(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	h := C.rb_hash_new()
	for key, value := range resp.Header {
		C.rb_hash_aset(h, RbString(key), StrSlice2RbArray(value))
	}
	return h
}
示例#4
0
文件: gohttp.go 项目: nurse/gohttp
//export goioClose
func goioClose(self C.VALUE) C.VALUE {
	v := (*reflect.Value)(C.GetGoStruct(self))
	if c, ok := v.Interface().(io.Closer); ok {
		c.Close()
		return C.Qtrue
	}
	return C.Qfalse
}
示例#5
0
文件: gohttp.go 项目: nurse/gohttp
//export goioRead
func goioRead(self C.VALUE) C.VALUE {
	v := (*reflect.Value)(C.GetGoStruct(self))
	r := v.Interface().(io.Reader)
	body, err := ioutil.ReadAll(r)
	if err != nil {
		rb_raise(C.rb_eArgError, "'%s'", err)
	}
	return RbBytes(body)
}
示例#6
0
文件: gohttp.go 项目: nurse/gohttp
//export goio_to_s
func goio_to_s(self C.VALUE) C.VALUE {
	v := (*reflect.Value)(C.GetGoStruct(self))
	switch v.Kind() {
	case reflect.Struct:
		return RbString(fmt.Sprintf("#<GoIO:%s>", v.Type().String()))
	case reflect.Chan, reflect.Map, reflect.Ptr, reflect.UnsafePointer:
		return RbString(fmt.Sprintf("#<GoIO:%s:0x%X>", v.Type().String(), v.Pointer()))
	default:
		return RbString(fmt.Sprintf("#<GoIO:%s>", v.Type().String()))
	}
}
示例#7
0
文件: gohttp.go 项目: nurse/gohttp
//export reqProto
func reqProto(self C.VALUE) C.VALUE {
	req := (*http.Request)(C.GetGoStruct(self))
	return RbString(req.Proto)
}
示例#8
0
文件: gohttp.go 项目: nurse/gohttp
//export respRequest
func respRequest(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	return reqNew(rb_cRequest, resp.Request)
}
示例#9
0
文件: gohttp.go 项目: nurse/gohttp
//export respProto
func respProto(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	return RbString(resp.Proto)
}
示例#10
0
文件: gohttp.go 项目: nurse/gohttp
//export respTransferEncoding
func respTransferEncoding(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	return StrSlice2RbArray(resp.TransferEncoding)
}
示例#11
0
文件: gohttp.go 项目: nurse/gohttp
//export respStatus
func respStatus(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	return RbString(resp.Status)
}
示例#12
0
文件: gohttp.go 项目: nurse/gohttp
//export respStatusCode
func respStatusCode(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	return INT2NUM(resp.StatusCode)
}
示例#13
0
文件: gohttp.go 项目: nurse/gohttp
//export reqMethod
func reqMethod(self C.VALUE) C.VALUE {
	req := (*http.Request)(C.GetGoStruct(self))
	return RbString(req.Method)
}
示例#14
0
文件: gohttp.go 项目: nurse/gohttp
//export respContentLength
func respContentLength(self C.VALUE) C.VALUE {
	resp := (*http.Response)(C.GetGoStruct(self))
	return INT64toNUM(resp.ContentLength)
}
示例#15
0
文件: gohttp.go 项目: nurse/gohttp
//export reqRequestURI
func reqRequestURI(self C.VALUE) C.VALUE {
	req := (*http.Request)(C.GetGoStruct(self))
	return RbString(req.RequestURI)
}
示例#16
0
文件: gohttp.go 项目: nurse/gohttp
//export reqTransferEncoding
func reqTransferEncoding(self C.VALUE) C.VALUE {
	req := (*http.Request)(C.GetGoStruct(self))
	return StrSlice2RbArray(req.TransferEncoding)
}
示例#17
0
文件: gohttp.go 项目: nurse/gohttp
//export reqContentLength
func reqContentLength(self C.VALUE) C.VALUE {
	req := (*http.Request)(C.GetGoStruct(self))
	return INT64toNUM(req.ContentLength)
}