//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) }
//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) }
//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 }
//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 }
//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) }
//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())) } }
//export reqProto func reqProto(self C.VALUE) C.VALUE { req := (*http.Request)(C.GetGoStruct(self)) return RbString(req.Proto) }
//export respRequest func respRequest(self C.VALUE) C.VALUE { resp := (*http.Response)(C.GetGoStruct(self)) return reqNew(rb_cRequest, resp.Request) }
//export respProto func respProto(self C.VALUE) C.VALUE { resp := (*http.Response)(C.GetGoStruct(self)) return RbString(resp.Proto) }
//export respTransferEncoding func respTransferEncoding(self C.VALUE) C.VALUE { resp := (*http.Response)(C.GetGoStruct(self)) return StrSlice2RbArray(resp.TransferEncoding) }
//export respStatus func respStatus(self C.VALUE) C.VALUE { resp := (*http.Response)(C.GetGoStruct(self)) return RbString(resp.Status) }
//export respStatusCode func respStatusCode(self C.VALUE) C.VALUE { resp := (*http.Response)(C.GetGoStruct(self)) return INT2NUM(resp.StatusCode) }
//export reqMethod func reqMethod(self C.VALUE) C.VALUE { req := (*http.Request)(C.GetGoStruct(self)) return RbString(req.Method) }
//export respContentLength func respContentLength(self C.VALUE) C.VALUE { resp := (*http.Response)(C.GetGoStruct(self)) return INT64toNUM(resp.ContentLength) }
//export reqRequestURI func reqRequestURI(self C.VALUE) C.VALUE { req := (*http.Request)(C.GetGoStruct(self)) return RbString(req.RequestURI) }
//export reqTransferEncoding func reqTransferEncoding(self C.VALUE) C.VALUE { req := (*http.Request)(C.GetGoStruct(self)) return StrSlice2RbArray(req.TransferEncoding) }
//export reqContentLength func reqContentLength(self C.VALUE) C.VALUE { req := (*http.Request)(C.GetGoStruct(self)) return INT64toNUM(req.ContentLength) }