本文整理汇总了Golang中github.com/shibukawa/curl_as_dsl/common.CurlOptions.OnlyHasContentTypeHeader方法的典型用法代码示例。如果您正苦于以下问题:Golang CurlOptions.OnlyHasContentTypeHeader方法的具体用法?Golang CurlOptions.OnlyHasContentTypeHeader怎么用?Golang CurlOptions.OnlyHasContentTypeHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/shibukawa/curl_as_dsl/common.CurlOptions
的用法示例。
在下文中一共展示了CurlOptions.OnlyHasContentTypeHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ClientNeeded
func ClientNeeded(options *common.CurlOptions) bool {
if options.Http2Flag || options.Insecure || options.Proxy != "" || options.User != "" || len(options.Cookie) > 0 {
return true
}
if len(options.AWSV2) > 0 {
return true
}
if options.OnlyHasContentTypeHeader() {
method := options.Method()
if method != "GET" && method != "POST" {
return true
}
return false
}
return true
}
示例2: ProcessCurlCommand
/*
Dispatcher function of curl command
This is an exported function and called from httpgen.
*/
func ProcessCurlCommand(options *common.CurlOptions) (string, interface{}) {
generator := NewGoGenerator(options)
if ClientNeeded(options) {
return processCurlFullFeatureRequest(generator)
}
method := options.Method()
onlyHasContentTypeHeader := options.OnlyHasContentTypeHeader()
if method == "POST" && onlyHasContentTypeHeader {
if options.ProcessedData.HasData() {
if options.Get {
return processCurlPostDataWithUrl(generator)
} else if len(options.ProcessedData) == 1 && options.ProcessedData[0].UseExternalFile() {
return processCurlPostSingleFile(generator)
} else {
return processCurlPostData(generator)
}
} else if options.ProcessedData.HasForm() {
return processCurlPostData(generator)
} else {
return processCurlSimple(generator)
}
}
if method == "GET" {
if len(options.ProcessedData) > 0 {
return processCurlGetDataWithUrl(generator)
} else {
return processCurlSimple(generator)
}
}
if !options.ProcessedData.HasData() && !options.ProcessedData.HasForm() {
return processCurlSimple(generator)
}
return "", nil
}