本文整理匯總了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
}