Comments (2)
You've asked a libcurl question.
USE curl.OPT_CUSTOMREQUEST
options to customize HTTP request method.
package main
import (
"fmt"
curl "github.com/andelf/go-curl"
)
func main() {
easy := curl.EasyInit()
defer easy.Cleanup()
easy.Setopt(curl.OPT_URL, "http://httpbin.org/")
easy.Setopt(curl.OPT_CUSTOMREQUEST, "OPTIONS")
// make a callback function
fooTest := func (buf []byte, userdata interface{}) bool {
println("DEBUG: size=>", len(buf))
println("DEBUG: content=>", string(buf))
return true
}
easy.Setopt(curl.OPT_WRITEFUNCTION, fooTest)
// for OPTIONS response, we use HEADERFUNCTION to fetch
easy.Setopt(curl.OPT_HEADERFUNCTION, fooTest)
if err := easy.Perform(); err != nil {
fmt.Printf("ERROR: %v\n", err)
}
}
You will got
DEBUG: content=> Access-Control-Allow-Methods: GET, POST, PUT, DELETE, PATCH, OPTIONS
in your output. :)
from go-curl.
It's working! Thank you!
from go-curl.
Related Issues (20)
- Perform() hangs when passing in false to WRITEFUNCTION HOT 10
- Issues when passing in multiple values to the OPT_HTTPHEADER HOT 2
- How store all Cookies in a file? HOT 1
- panic: runtime error: invalid memory address or nil pointer dereference
- 请求curl返回的各项时间为 0 HOT 1
- is curl_global_init handled safely? is the library thread-safe? HOT 6
- Couldn't read Getinfo Informations
- use C.struct, not _Ctype_struct
- Cannot compile after march 14 update HOT 9
- cannot find the PUT and GET method implementation
- Is there functionality for running the requests through torsockets?
- how to know the compiled in libcurl version?
- HTTP2 support?
- Get cURL error code HOT 1
- Problem in building go software for windows HOT 4
- Getting SSL certificate expiry date
- Windows: callback.go:8:10: fatal error: curl/curl.h: No such file or directory HOT 1
- curl 7.56 deprecations
- library not supporting curl version 8.0.X or higher
- Not building at Docker
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-curl.