How do I use the --header option to send cookies with Siege? - cookies

I have just started to use Siege to do load/stressing test on a new web server. I am trying to test on my most resource/performance heavy script, but the script requires cookies. What is the proper format for using the --header option in siege?
I have tried this with no luck:
siege --header="Set-Cookie: PHPSESSID=--COOKIE--; iptoken=--COOKIE--" http://www.myurl.com/script.php,
There is no documentation on this that I could find, so any ideas/suggestions would be appreciated.

The answer is to use --header="Cookie: --COOKIE_DATA--" (ref. wiki.wsmoak.net/cgi-bin/wiki.pl?Siege).

Related

CSRF Token error when attempting to post from CURL to an API endpoint I control. How do I write the request?

I have not utilized this part of Django before, but I have an endpoint which is giving me a 403 error and is telling me that my request needs a csrf token. I was trying to figure out how best to get this since I was attempting to set up a bunch of curl requests to handle some simple queries to the endpoint. Likewise, I was thinking to also use POSTman, but I was not sure where documentation is to handle these request.
I have seen the cookie csrftoken, but when I was attempting to curl with it, it was still giving me a 403. thought it would looking something like this:
curl -d #profilepicturev2.png -b "csrftoken=Ebfn2OlfhSwFjAEQdoQon7wUjbynFoJqrtHMNPla3cy7ZfCMT9cxZ3OQHsbaedam" http://127.0.0.1:8000/api/files/uploader
Maybe I am mistaken? I am trying to send a photo to the server, so i was thinking that this would be correct and wasnt sure if i needed to add additional params in order to append additional data information.
i need to see your code, but i think you need to install "pillow" to send pictures in django !

Using the Vimeo API, how do I replace all videos in a Vimeo album?

Using curl, I'm trying to create a working Vimeo API call that replaces the videos in a Vimeo album with a different set of videos. (The docs are here.) I am successfully deleting the existing videos from the album but my new video info seems to be invisible to Vimeo. Vimeo responds with a 201 ("created") instead of the 200 I'm looking for.
Here is my curl command (with subs for actual data):
curl -H "Authorization: bearer 123abc456def" -X PUT --data "videos=%2Fvideos%2F11111%2C%2Fvideos%2F22222%2C%2Fvideos%2F33333" "https://api.vimeo.com/me/albums/7777777/videos"
I don't know what I'm doing wrong and the Vimeo API docs & playground don't give me the answers I need. My questions and observations:
Should I be url encoding the new video URIs (e.g. 11111,22222, etc)? I have also tried without url encoding and it made no difference. But then the 201 might be telling me it didn't get as far as handling my replacement URIs.
a PUT is required for this operation. I have used PUT successfully to add a video to an existing album (in LiveCode, haven't tried it with curl)
I got the same results when I tried this PUT in LiveCode. I moved the request to curl because more people are familiar with curl.
This is my first rodeo using the Vimeo API. It's a great, vast resource and I've had no problems working with it until this. I'm just stuck on this item and really need it to work!
Thanks for any help you can offer.
This is an ancient, deprecated way of handling batch editing. I'm not sure how it still exists. We will move it to the proper batch creation standard in 3.4.
I think the existing system is supposed to be a comma separated list of video id's, so
curl -H "Authorization: bearer 123abc456def" -X PUT --data "videos=11111%2C22222%2C33333" "https://api.vimeo.com/me/albums/7777777/videos"
is likely the proper request.

Qt : Accessing Secure Objects using session-id from a server

I am working on a Qt application in which I would like to retrieve objects which are tagged #Secured in the Spring-MVC based web-application. I have written the code on the server side for REST authentication and if I use the 'curl' tool, then I am able to access secure services on the server. I would like to know if there is anyway I can replicate the way I am accessing secured services in a QT application. Any help would be nice. Thanks a lot.
curl code :
curl -i -X POST -d j_username=email#email.de -d j_password=password -c /home/username/cookies.txt http://localhost:8080/j_spring_security_check
And for using the session-id to access secure services, I do :
curl -i --header "Accept:application/json" -X GET -b /home/cookies.txt http://localhost:8080/secure_service_method
How can I achieve the same thing in QT. Any help would be nice. Please note, I am not that of an expert in Qt, so please be patient. Thanks a lot.
Converting my comments into this answer:
Judging from your curl command you probably just need to send a POST request and handle the cookies using Qt . Qt provides everything necessary to accomplish this task, have a look at QNetworkAccessManager::post and QNetworkAccessManager::setCookieJar.
The basic steps you need to implement will look like this:
1.) Setup:
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
manager->setCookieJar(new QNetworkCookieJar(manager));
connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*)));
2.) Request the cookie
QNetworkRequest request;
request.setUrl(QUrl("http://localhost:8080/j_spring_security_check"));
QByteArray postData;
postData.append("j_username=email#email.de&j_password=password");
manager->post(request,postData);
3.) Use the manager object which then has the cookie to request the protected files.

Calling REST WS from command line

I read that REST WS can be called from a command line. I know that they can be invoked from program code, but how directly from command line? I looked around the internet to know how this can be done, but didn't find any information on this. Can anyone please tell me how this can be done? I have developed a rest ws app in grails.
You can use curl from the commandline of any unix-like os.
For example, you can test some sample Facebook API like this:
curl https://graph.facebook.com/19292868552
or to POST:
curl -X POST -d "param1=value1&param2=value2" http://example.com/resource.cgi
You could use curl to ask a URL. I guess your web service can be queried using HTTP?
http://curl.haxx.se/
I believe you want to use cURL to do that.

API for document format conversion

I am looking for a RESTful web service to which I can send a document (doc, docx, xls, xlsx, ppt, pptx, and tiff at a minimum) for conversion to pdf and swf.
The reason I need swf in addition to pfd is so that I can display the document in the browser using a flash-based document viewer such as FlexPaper.
I basically want transloadit.com for documents.
One option is to use the Scribd API, download the pdf, and use swftools to convert the pdf to swf. However I am interested in alternatives.
doxument.com might be what you looking for. They do offer some kind of REST API. I'm not sure about the formats though.
I am developing on http://webservices.io which is in beta and offers document conversion via a REST API.
While it also doesn't do all the conversions you are asking for, it does have docx and xlsx support. See matrix with supported conversions
Aspose library is best of the best http://www.aspose.com/ Use it for create your own service
Although it's an old question, however just want to share another solution for future reference.
GroupDocs.Conversion Cloud REST API is another option to convert back and forth between over 65+ types of documents and images, including all Microsoft Office and OpenDocument file formats, PDF documents, HTML, CAD, raster images and much more.
cURL sample Code:
### Retrieve access token
### TODO: Get your AppSID and AppKey at https://dashboard.groupdocs.cloud (free registration is required).
curl --request POST https://api.groupdocs.cloud/connect/token
--header "Content-Type: application/x-www-form-urlencoded"
--data "grant_type=client_credentials&client_id=[APP_SID]&client_secret=[APP_KEY]"
### Convert and Add Watermark
curl --request POST "https://api.groupdocs.cloud/v2.0/conversion"
--header "authorization: Bearer [ACCESS_TOKEN]"
--header "accept: application/json"
--header "Content-Type: application/json" --data "{ "FilePath": "test_doc.docx", "Format": "pdf", "ConvertOptions": { "FromPage": 1, "PagesCount": 1, "WatermarkOptions": { "text": "Watermark" } }, "OutputPath": "Output"}"
I work with Aspose as developer evangelist.