Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 314178 Details for
Bug 458919
curl/cannot CONNECT HTTP request over proxy using ntlm2 auth
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
patch based on upstream code
curl-header.patch (text/plain), 9.89 KB, created by
ritz
on 2008-08-13 08:21:59 UTC
(
hide
)
Description:
patch based on upstream code
Filename:
MIME Type:
Creator:
ritz
Created:
2008-08-13 08:21:59 UTC
Size:
9.89 KB
patch
obsolete
>diff -Naur curl-7.12.1.orig/lib/http.c curl-7.12.1/lib/http.c >--- curl-7.12.1.orig/lib/http.c 2008-08-13 00:18:52.000000000 +0530 >+++ curl-7.12.1/lib/http.c 2008-08-13 00:48:00.000000000 +0530 >@@ -664,6 +664,8 @@ > }; > typedef struct send_buffer send_buffer; > >+static CURLcode add_custom_headers(struct connectdata *conn, >+ send_buffer *req_buffer); > static CURLcode > add_buffer(send_buffer *in, const void *inptr, size_t size); > >@@ -739,35 +741,48 @@ > > *bytes_written += amount; > >- if((size_t)amount != size) { >- /* The whole request could not be sent in one system call. We must queue >- it up and send it later when we get the chance. We must not loop here >- and wait until it might work again. */ >- >- size -= amount; >- >- ptr = in->buffer + amount; >- >- /* backup the currently set pointers */ >- http->backup.fread = conn->fread; >- http->backup.fread_in = conn->fread_in; >- http->backup.postdata = http->postdata; >- http->backup.postsize = http->postsize; >- >- /* set the new pointers for the request-sending */ >- conn->fread = (curl_read_callback)readmoredata; >- conn->fread_in = (void *)conn; >- http->postdata = ptr; >- http->postsize = (curl_off_t)size; >+ if(http) { >+ if((size_t)amount != size) { >+ /* The whole request could not be sent in one system call. We must queue >+ it up and send it later when we get the chance. We must not loop here >+ and wait until it might work again. */ >+ >+ size -= amount; >+ >+ ptr = in->buffer + amount; >+ >+ /* backup the currently set pointers */ >+ http->backup.fread = conn->fread; >+ http->backup.fread_in = conn->fread_in; >+ http->backup.postdata = http->postdata; >+ http->backup.postsize = http->postsize; >+ >+ /* set the new pointers for the request-sending */ >+ conn->fread = (curl_read_callback)readmoredata; >+ conn->fread_in = (void *)conn; >+ http->postdata = ptr; >+ http->postsize = (curl_off_t)size; > >- http->send_buffer = in; >- http->sending = HTTPSEND_REQUEST; >+ http->send_buffer = in; >+ http->sending = HTTPSEND_REQUEST; > >- return CURLE_OK; >+ return CURLE_OK; >+ } >+ http->sending = HTTPSEND_BODY; >+ /* the full buffer was sent, clean up and return */ > } >- http->sending = HTTPSEND_BODY; >- /* the full buffer was sent, clean up and return */ >- } >+ else { >+ if((size_t)amount != size) >+ /* We have no continue-send mechanism now, fail. This can only happen >+ when this function is used from the CONNECT sending function. We >+ currently (stupidly) assume that the whole request is always sent >+ away in the first single chunk. >+ >+ This needs FIXing. >+ */ >+ return CURLE_SEND_ERROR; >+ } >+ } > if(in->buffer) > free(in->buffer); > free(in); >@@ -892,9 +907,15 @@ > } > > /* >- * ConnectHTTPProxyTunnel() requires that we're connected to a HTTP proxy. This >- * function will issue the necessary commands to get a seamless tunnel through >- * this proxy. After that, the socket can be used just as a normal socket. >+ * ConnectHTTPProxyTunnel() requires that we're connected to a HTTP >+ * proxy. This function will issue the necessary commands to get a seamless >+ * tunnel through this proxy. After that, the socket can be used just as a >+ * normal socket. >+ * >+ * This badly needs to be rewritten. CONNECT should be sent and dealt with >+ * like any ordinary HTTP request, and not specially crafted like this. This >+ * function only remains here like this for now since the rewrite is a bit too >+ * much work to do at the moment. > */ > > CURLcode Curl_ConnectHTTPProxyTunnel(struct connectdata *conn, >@@ -918,6 +939,7 @@ > char *line_start; > char *host_port; > curl_socket_t tunnelsocket = conn->sock[sockindex]; >+ send_buffer *req_buffer; > > #define SELECT_OK 0 > #define SELECT_ERROR 1 >@@ -935,6 +957,12 @@ > conn->newurl = NULL; > } > >+ /* initialize a dynamic send-buffer */ >+ req_buffer = add_buffer_init(); >+ >+ if(!req_buffer) >+ return CURLE_OUT_OF_MEMORY; >+ > host_port = aprintf("%s:%d", hostname, remote_port); > if(!host_port) > return CURLE_OUT_OF_MEMORY; >@@ -942,19 +970,53 @@ > /* Setup the proxy-authorization header, if any */ > result = Curl_http_output_auth(conn, (char *)"CONNECT", host_port, TRUE); > if(CURLE_OK == result) { >+ char *host=(char *)""; >+ const char *proxyconn=""; >+ char *ptr; >+ >+ ptr = checkheaders(data, "Host:"); >+ if(!ptr) { >+ host = aprintf("Host: %s\r\n", host_port); >+ if(!host) >+ result = CURLE_OUT_OF_MEMORY; >+ } >+ ptr = checkheaders(data, "Proxy-Connection:"); >+ if(!ptr) >+ proxyconn = "Proxy-Connection: Keep-Alive\r\n"; >+ >+ if(CURLE_OK == result) { >+ /* Send the connect request to the proxy */ >+ /* BLOCKING */ > >- /* OK, now send the connect request to the proxy */ > result = >- Curl_sendf(tunnelsocket, conn, >- "CONNECT %s:%d HTTP/1.0\015\012" >- "%s" >- "%s" >- "\r\n", >- hostname, remote_port, >- conn->bits.proxy_user_passwd? >- conn->allocptr.proxyuserpwd:"", >- data->set.useragent?conn->allocptr.uagent:"" >- ); >+ add_bufferf(req_buffer, >+ "CONNECT %s:%d HTTP/1.0\r\n" >+ "%s" /* Host: */ >+ "%s" /* Proxy-Authorization */ >+ "%s" /* User-Agent */ >+ "%s", /* Proxy-Connection */ >+ hostname, remote_port, >+ host, >+ conn->allocptr.proxyuserpwd? >+ conn->allocptr.proxyuserpwd:"", >+ data->set.useragent?conn->allocptr.uagent:"", >+ proxyconn); >+ >+ if(CURLE_OK == result) >+ result = add_custom_headers(conn, req_buffer); >+ >+ if(host && *host) >+ free(host); >+ >+ if(CURLE_OK == result) >+ /* CRLF terminate the request */ >+ result = add_bufferf(req_buffer, "\r\n"); >+ >+ if(CURLE_OK == result) >+ /* Now send off the request */ >+ result = add_buffer_send(req_buffer, conn, >+ &data->info.request_size); >+ } > if(result) > failf(data, "Failed sending CONNECT to proxy"); > } >@@ -1207,6 +1269,43 @@ > return CURLE_OK; > } > >+static CURLcode add_custom_headers(struct connectdata *conn, >+ send_buffer *req_buffer) >+{ >+ CURLcode result = CURLE_OK; >+ char *ptr; >+ struct curl_slist *headers=conn->data->set.headers; >+ >+ while(headers) { >+ ptr = strchr(headers->data, ':'); >+ if(ptr) { >+ /* we require a colon for this to be a true header */ >+ >+ ptr++; /* pass the colon */ >+ while(*ptr && isspace((int)*ptr)) >+ ptr++; >+ >+ if(*ptr) { >+ /* only send this if the contents was non-blank */ >+ >+ if(conn->allocptr.host && >+ /* a Host: header was sent already, don't pass on any custom Host: >+ header as that will produce *two* in the same request! */ >+ curl_strnequal("Host:", headers->data, 5)) >+ ; >+ else { >+ >+ result = add_bufferf(req_buffer, "%s\r\n", headers->data); >+ if(result) >+ return result; >+ } >+ } >+ } >+ headers = headers->next; >+ } >+ return result; >+} >+ > /* > * Curl_http() gets called from the generic Curl_do() function when a HTTP > * request is to be performed. This creates and sends a properly constructed >@@ -1444,10 +1543,14 @@ > } > > >- if(!checkheaders(data, "Pragma:")) >- http->p_pragma = "Pragma: no-cache\r\n"; >+ http->p_pragma = >+ (!checkheaders(data, "Pragma:") && >+ (conn->bits.httpproxy && !conn->bits.tunnel_proxy) )? >+ "Pragma: no-cache\r\n":NULL; > > if(!checkheaders(data, "Accept:")) >+ http->p_pragma = "Pragma: no-cache\r\n"; >+ http->p_pragma = "Pragma: no-cache\r\n"; > http->p_accept = "Accept: */*\r\n"; > > if(( (HTTPREQ_POST == httpreq) || >@@ -1551,7 +1654,6 @@ > data->set.httpversion==CURL_HTTP_VERSION_1_0?"1.0":"1.1"; > > send_buffer *req_buffer; >- struct curl_slist *headers=data->set.headers; > curl_off_t postsize; /* off_t type to be able to hold a large file size */ > > /* initialize a dynamic send-buffer */ >@@ -1574,6 +1676,7 @@ > "%s" /* accept */ > "%s" /* accept-encoding */ > "%s" /* referer */ >+ "%s" /* Proxy-Connection */ > "%s",/* transfer-encoding */ > > request, >@@ -1592,6 +1695,8 @@ > (data->set.encoding && *data->set.encoding && conn->allocptr.accept_encoding)? > conn->allocptr.accept_encoding:"", > (data->change.referer && conn->allocptr.ref)?conn->allocptr.ref:"" /* Referer: <data> */, >+ (conn->bits.httpproxy && !conn->bits.tunnel_proxy)? >+ "Proxy-Connection: Keep-Alive\r\n":"", > te > ); > >@@ -1692,25 +1797,9 @@ > return result; > } > >- while(headers) { >- ptr = strchr(headers->data, ':'); >- if(ptr) { >- /* we require a colon for this to be a true header */ >- >- ptr++; /* pass the colon */ >- while(*ptr && isspace((int)*ptr)) >- ptr++; >- >- if(*ptr) { >- /* only send this if the contents was non-blank */ >- >- result = add_bufferf(req_buffer, "%s\r\n", headers->data); >- if(result) >- return result; >- } >- } >- headers = headers->next; >- } >+ result = add_custom_headers(conn, req_buffer); >+ if(result) >+ return result; > > http->postdata = NULL; /* nothing to post at this point */ > Curl_pgrsSetUploadSize(data, 0); /* upload size is 0 atm */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 458919
:
314178
|
326710