Bug 14762 – Do not use other method options on persistent connection.
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-07-02T15:50:00Z
Last change time
2015-10-04T18:20:05Z
Assigned to
nobody
Creator
karo+dlang
Comments
Comment #0 by karo+dlang — 2015-07-02T15:50:27Z
without clearing options in perform function, libcurl use previous options.
- Prefer CUSTOM request by libcurl
https://github.com/bagder/curl/blob/master/lib/http.c#L1834
// prefer_custom_request.d
import std.net.curl;
void main()
{
auto url = "http://localhost:8080/";
auto http = HTTP();
// any CUSTOM request
trace(url, http);
// Prefer CUSTOM request by libcurl
// https://github.com/bagder/curl/blob/master/lib/http.c#L1834
auto a = get(url, http);
assert(HTTP.Method.get == http.method);
assert(a == "GET", a); // => a is "TRACE"
}
- Change to PUT after PUT by libcurl
https://github.com/bagder/curl/blob/master/lib/http.c#L1830
// put_post.d
import std.net.curl;
void main()
{
auto http = HTTP();
auto url = "http://localhost:8080/";
auto a = put(url, "", http);
assert(a == "PUT", a);
// Change to PUT after PUT by libcurl
// https://github.com/bagder/curl/blob/master/lib/http.c#L1830
auto b = post(url, "", http);
assert(b == "POST", b); // b is "PUT"
}
It is http server to respond method name by golang.
// method.go
// go run method.go
package main
import (
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(r.Method))
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
Comment #1 by github-bugzilla — 2015-07-28T07:28:18Z