http-post

How to RAW POST huge XML file with curl - PHP

最后都变了- 提交于 2019-11-29 07:23:54
is there a way of doing curl -X POST -H "Content-Type:application/xml" --data @myfile.xml http://example.com but directly in PHP? CURLOPT_PUT / CURLOPT_UPLOAD as well as file_get_contents as well as exec are not a solutions as it must be POST and the file is huge so must be streamed. Any ideas? I had a similar problem trying to feed huge ingestion files to elasticsearch's bulk API from PHP, until I realized that the bulk API endpoint accepted PUT requests. Anyway, this code performs POST requests with huge files: $curl = curl_init(); curl_setopt( $curl, CURLOPT_PUT, 1 ); curl_setopt( $curl,

Host name may not be null in HttpResponse execute for android

喜你入骨 提交于 2019-11-29 06:22:17
I get the error "Target host must not be null, or set in parameters". I DO have Internet permission in my manifest file I have put 'http://' before my Url I DO encode the URL This is my code: String url = "http://maps.google.com/maps/api/directions/json?origin=1600 Pennsylvania Avenue NW, Washington, DC 20500&destination=1029 Vermont Ave NW, Washington, DC 20005&sensor=false"; HttpClient httpclient = new DefaultHttpClient(); String goodURL = convertURL(url);//change weird characters for %etc HttpPost httppost = new HttpPost(goodURL); HttpResponse response = httpclient.execute(httppost); In 5th

show “webpage has expired” on back button

二次信任 提交于 2019-11-29 06:08:36
What is the requirement for the browser to show the ubiquitous "this page has expired" message when the user hits the back button? What are some user-friendly ways to prevent the user from using the back button in a webapp? Steve Wortham Well, by default whenever you're dealing with a form POST, and then the user hits back and then refresh then they'll see the message indicating that the browser is resubmitting data. But if the page is set to expire immediately then they won't even have to hit refresh and they'll see the page has expired message when they hit back. To avoid both messages there

Send data to page loaded in WebView

♀尐吖头ヾ 提交于 2019-11-29 04:51:10
I have a WebView in my app and I load http://mysite.com/somepage.php I know I can pass data using the GET method because that would just be right in the URL string. I was wondering how I could pass data to the page using the POST method. I tried searching but I cannot find anything specific. Thanks. There's a method called postUrl in WebView . public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WebView webView = new WebView(this); setContentView(webView); String url = "http://mysite.com/somepage.php"; String postData = "postvar=value"; webView.postUrl(url,

How to keep HttpClient Connection Keep-Alive?

时光总嘲笑我的痴心妄想 提交于 2019-11-29 04:13:11
I am working HttpClient POST method. I need to create HttpClient once and should use Keep Alive Connection. But I think in my case , its establishing a new connection every time. So, i need to use a Keep Alive connection for HttpClient . Here is my code snippet any help would be appreciated lot. ClientConnectionManager mgr = httpclient_recv.getConnectionManager(); hp = httpclient_recv.getParams(); httpclient_recv = new DefaultHttpClient( new ThreadSafeClientConnManager(hp,mgr.getSchemeRegistry()), hp); while (true) { try { java.util.logging.Logger.getLogger("org.apache.http.wire") .setLevel

Retrofit throwing IllegalArgumentException exception for asynchronous FormUrlEncoded DELETE call

人盡茶涼 提交于 2019-11-29 03:49:02
I'm trying to make an asynchronous POST and DELETE which is form url encoded using Retrofit in Android 4.4 Here is my client - @FormUrlEncoded @POST(INetwork.API_BASE_PREFIX + "/memberships.json") void join(@Field("id") String id, Callback<?> cb); @FormUrlEncoded @DELETE(INetwork.API_BASE_PREFIX + "/memberships.json") void leave(@Field("id") String id, Callback<?> cb); And this is the exception - java.lang.IllegalArgumentException: IRepositoryClient.leave: FormUrlEncoded can only be specified on HTTP methods with request body (e.g., @POST). at retrofit.RestMethodInfo.methodError(RestMethodInfo

Authentication Error when using HttpPost with DefaultHttpClient on Android

非 Y 不嫁゛ 提交于 2019-11-29 03:47:50
I'm running into a strange problem using HttpClient. I am using a DefaultHttpClient() with HttpPost. I was using HttpGet with 100% success but now trying to switch to HttpPost as the REST API I'm using wants POST parameters rather than GET. (Only for some API calls though so I know that the GET calls were working fine so it's not a fault of the API). Also, I tried using HttpPost on a simple php script I wrote that looks for a POST parameter 'var' and echoes it to screen, passing this parameters as follows worked fine: List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

Angular JS does not allow preventDefault or return false to work on form submission

狂风中的少年 提交于 2019-11-29 02:52:35
I have a form I'd like to deliver via AJAX : <form class="form-inline ng-pristine" ng-submit="sendForm()" method="post" action="/sign_up" accept-charset="UTF-8"> $scope.sendForm = (e) -> e.preventDefault -> console.log 'sendForm()' return false The console.log appears, and immediately it delivers the form. It ignores both the e.preventDefault() , and the return false . AngularJS reminds me of the honey badger. It just doesn't care. I know I am pretty late to the party, but in case you did not figure it out yet, you can keep the action and make sure the form is not actually submitted by passing

How to post data for WebView android

点点圈 提交于 2019-11-29 02:27:24
问题 I need to post data to Webview. I found from some of the links the below code: WebView webview = new WebView(this); setContentView(webview); String url = "http://www.example.com"; String postData = username=my_username&password=my_password"; webview.postUrl(url",EncodingUtils.getBytes(postData, "BASE64")); But in my android studio I see EncodingUtils as deprecated Can anyone help me what is the alternative for EncodingUtils to post data to Android WebView? 回答1: Try like below... WebView

400 Bad request on Spring Jquery Ajax Post

青春壹個敷衍的年華 提交于 2019-11-29 02:16:10
I'm getting a 400 bad request on this POST request. Any idea what the issue is here ? Logs are here . Controller @Controller public class AjaxController { @RequestMapping(value="/addKeys", method=RequestMethod.POST, consumes="application/json; charset=UTF-8") public ResponseEntity<String> addKeys(@RequestParam(value="keys") ArrayList<Keys> keys){ System.out.println("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"+keys); } } context-Servlet.xml <beans> <mvc:annotation-driven /> <context:component-scan base-package="com.canon.fw.controller" /> <bean id="defaultViews" class="org